Начало обработки по ссылкам
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
namespace ContingentParser\Http;
|
||||
|
||||
use ContingentParser\Logger\HttpLogger;
|
||||
use ContingentParser\Printer;
|
||||
use CurlHandle;
|
||||
/**
|
||||
* Summary of CurlHelper
|
||||
@@ -38,7 +39,7 @@ final class CurlHelper
|
||||
curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, 90);
|
||||
}
|
||||
/**
|
||||
* Прекратить сессии
|
||||
* Прекратить сессию
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
@@ -55,7 +56,6 @@ final class CurlHelper
|
||||
if ($this->checkLocation($this->url, $html)) {
|
||||
$html = $this->getContent();
|
||||
}
|
||||
$this->reportError();
|
||||
return $html;
|
||||
}
|
||||
/**
|
||||
@@ -77,14 +77,14 @@ final class CurlHelper
|
||||
* Сообщить об ошибке
|
||||
* @return void
|
||||
*/
|
||||
private function reportError() : void
|
||||
public function reportError() : void
|
||||
{
|
||||
$httpLogger = new HttpLogger('log/http-curl.log');
|
||||
|
||||
$httpCode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
|
||||
|
||||
if ($httpCode != 200 && $httpCode != 0) {
|
||||
print("\033[91mHTTP-code: $httpCode\033[0m\n");
|
||||
Printer::println("HTTP-code: $httpCode", 'red');
|
||||
$message = implode(' ', $this->site) . ' HTTP-code(' . $httpCode.')';
|
||||
$httpLogger->log($message, $httpCode);
|
||||
} else if ($httpCode == 0) {
|
||||
@@ -93,7 +93,7 @@ final class CurlHelper
|
||||
$message .= " cURL error ({$errno}): ".curl_strerror($errno);
|
||||
$httpLogger->log($message);
|
||||
} else {
|
||||
print("\033[94mHTTP-code: $httpCode\033[0m\n");
|
||||
Printer::println("HTTP-code: $httpCode", 'blue');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user