Добавлен цикл проверки сайтов

This commit is contained in:
2024-08-12 15:14:49 +03:00
parent 0b56cd37b5
commit 6b7199a326
115 changed files with 15964 additions and 88 deletions

View File

@ -20,7 +20,7 @@ class ContingentParser
"numberBMF" => "th",
"numberP" => "th",
"numberPF" => "th",
"numberAll" => "th"
"numberAll" => ["th", "td"]
];
public function __construct(string $html, string $template)
@ -36,7 +36,14 @@ class ContingentParser
{
$data = array();
foreach (self::FIELDS as $field => $tag) {
$data[$field] = $this->xpath->query($this->template . $tag . "[@itemprop=\"$field\"]");
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;
}
}
return $data;
}
@ -46,7 +53,7 @@ class ContingentParser
$data = $this->parse();
$records = array();
for ($i = 0; $i < $data['numberAll']->length; $i++) {
for ($i = 0; $i < $data['eduCode']->length; $i++) {
$contingentRow = new ContingentRow(
$data['eduCode']->item($i)->textContent,
$data['eduName']->item($i)->textContent,