Добавлен цикл проверки сайтов
This commit is contained in:
@ -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,
|
||||
|
Reference in New Issue
Block a user