Исправлена обработка разметки с кодировкой windows-1251
This commit is contained in:
@ -26,8 +26,16 @@ class ContingentParser
|
||||
public function __construct(string $html, string $template)
|
||||
{
|
||||
libxml_use_internal_errors(true);
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadHTML(mb_convert_encoding($html,'HTML-ENTITIES','UTF-8'));
|
||||
$dom = new \DOMDocument(
|
||||
encoding: "UTF-8"
|
||||
);
|
||||
$html = mb_convert_encoding(
|
||||
$html,
|
||||
'UTF-8',
|
||||
mb_detect_encoding($html, 'UTF-8, windows-1251')
|
||||
);
|
||||
$html = str_replace('windows-1251','utf-8', $html);
|
||||
$dom->loadHTML($html);
|
||||
$this->xpath = new \DOMXPath($dom);
|
||||
$this->template = $template;
|
||||
}
|
||||
@ -52,7 +60,8 @@ class ContingentParser
|
||||
{
|
||||
$data = $this->parse();
|
||||
$records = array();
|
||||
|
||||
// var_dump($data);
|
||||
// exit(0);
|
||||
if ($data == null) return [];
|
||||
|
||||
$equal = $data['eduName']->length;
|
||||
|
@ -69,7 +69,7 @@ class Database
|
||||
Logger::log(self::$logFile, "Запрос выполнен успешно!");
|
||||
} catch (PDOException $e) {
|
||||
// При ошибке запроса сохраняем валидные данные в yaml-файл
|
||||
$yaml = Yaml::dump($params);
|
||||
$yaml = Yaml::dump([$params]);
|
||||
file_put_contents(__DIR__ . '/not-recorded-in-db.yaml', $yaml, FILE_APPEND);
|
||||
$message = "Ошибка запроса:" . $e->getMessage();
|
||||
Logger::log(self::$logFile, $message);
|
||||
|
Reference in New Issue
Block a user