Добавлено логирование и исправлены некоторые ошибки в классах

This commit is contained in:
2024-08-16 13:44:49 +03:00
parent f06eee3e95
commit 8462c1907b
9 changed files with 1604 additions and 290 deletions

View File

@ -12,14 +12,14 @@ class ContingentParser
"eduName" => "td",
"eduLevel" => "td",
"eduForm" => "td",
"numberBF" => "th",
"numberBFF" => "th",
"numberBR" => "th",
"numberBRF" => "th",
"numberBM" => "th",
"numberBMF" => "th",
"numberP" => "th",
"numberPF" => "th",
// "numberBF" => "th",
// "numberBFF" => "th",
// "numberBR" => "th",
// "numberBRF" => "th",
// "numberBM" => "th",
// "numberBMF" => "th",
// "numberP" => "th",
// "numberPF" => "th",
"numberAll" => ["th", "td"]
];
@ -41,7 +41,7 @@ class ContingentParser
} else {
$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;
$data[$field] = $th->length > $td->length ? $th : $td;
}
}
@ -53,6 +53,19 @@ class ContingentParser
$data = $this->parse();
$records = array();
// var_dump($data['eduName']->item(0));
// exit(0);
$equel = $data['eduName']->length;
foreach ($data as $field) {
if ($field->length == 0) {
return [];
}
if ($field->length != $equel) {
return [];
}
}
for ($i = 0; $i < $data['eduCode']->length; $i++) {
$contingentRow = new ContingentRow(
$data['eduCode']->item($i)->textContent,