sveden-parser/app/app.php

48 lines
1.3 KiB
PHP
Raw Normal View History

2024-08-08 13:32:27 +03:00
<?php
namespace App;
use App\Library\ContingentParser;
2024-08-08 13:32:27 +03:00
use App\Library\Database;
use GuzzleHttp\Client;
$dbconfig = [
"host" => "10.90.1.201",
"database1" => "opendata",
"database2" => "niimko",
2024-08-08 13:32:27 +03:00
"user" => "niimko_user",
"password" => "MOhA17FeboXE"
];
$dbOpendata = new Database(
"mysql:host={$dbconfig['host']};dbname={$dbconfig['database1']}",
2024-08-08 13:32:27 +03:00
$dbconfig['user'],
$dbconfig['password']
);
$dbNiimko = new Database(
"mysql:host={$dbconfig['host']};dbname={$dbconfig['database2']}",
$dbconfig['user'],
$dbconfig['password']
);
2024-08-08 13:32:27 +03:00
$client = new Client();
$response = $client->get('https://marsu.ru/sveden/education/eduChislen.php');
$html = $response->getBody()->getContents();
$parser = new ContingentParser($html, '//tr[@itemprop="eduChislen"]//');
$contingent = $parser->getDataTable();
$specializations = $dbNiimko->selectWhere('s_specs', ['id', 'kod'], ['oopkodes' => 'gos3p']);
foreach ($contingent as $key => $con) {
$needle = $con['spec_code'];
foreach ($specializations as $spec) {
if ($needle == $spec['kod']) {
$contingent[$key] += ['spec_id' => $spec['id']];
}
}
}
// $dbOpendata->insert('sveden_education_contingent', $data);
// $dbOpendata = $db->select('sveden_education_contingent');
2024-08-08 13:32:27 +03:00
echo "<pre>";
print_r($contingent);
2024-08-08 13:32:27 +03:00
echo "</pre>";