Решена проблема кодировок

This commit is contained in:
2024-08-12 16:58:12 +03:00
parent 6b7199a326
commit 9ae73e81cf
4 changed files with 7933 additions and 20 deletions

View File

@ -27,7 +27,7 @@ class ContingentParser
{
libxml_use_internal_errors(true);
$dom = new \DOMDocument();
$dom->loadHTML($html);
$dom->loadHTML(mb_convert_encoding($html,'HTML-ENTITIES','UTF-8'));
$this->xpath = new \DOMXPath($dom);
$this->template = $template;
}
@ -39,9 +39,9 @@ class ContingentParser
if (!is_array($tag)) {
$data[$field] = $this->xpath->query($this->template . $tag . "[@itemprop=\"$field\"]");
} else {
$x = $this->xpath->query($this->template . $tag[0] . "[@itemprop=\"$field\"]");
$y = $this->xpath->query($this->template . $tag[1] . "[@itemprop=\"$field\"]");
$data[$field] = $x > $y ? $x : $y;
$th = $this->xpath->query($this->template . $tag[0] . "[@itemprop=\"$field\"]");
$td = $this->xpath->query($this->template . $tag[1] . "[@itemprop=\"$field\"]");
$data[$field] = $th > $td ? $th : $td;
}
}