2024-08-08 13:32:27 +03:00
|
|
|
<?php
|
|
|
|
namespace App;
|
|
|
|
|
2024-08-08 16:38:54 +03:00
|
|
|
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",
|
2024-08-08 16:38:54 +03:00
|
|
|
"database1" => "opendata",
|
|
|
|
"database2" => "niimko",
|
2024-08-08 13:32:27 +03:00
|
|
|
"user" => "niimko_user",
|
|
|
|
"password" => "MOhA17FeboXE"
|
|
|
|
];
|
|
|
|
|
2024-08-08 16:38:54 +03:00
|
|
|
$dbOpendata = new Database(
|
|
|
|
"mysql:host={$dbconfig['host']};dbname={$dbconfig['database1']}",
|
2024-08-08 13:32:27 +03:00
|
|
|
$dbconfig['user'],
|
|
|
|
$dbconfig['password']
|
|
|
|
);
|
|
|
|
|
2024-08-08 16:38:54 +03:00
|
|
|
$dbNiimko = new Database(
|
|
|
|
"mysql:host={$dbconfig['host']};dbname={$dbconfig['database2']}",
|
|
|
|
$dbconfig['user'],
|
|
|
|
$dbconfig['password']
|
|
|
|
);
|
2024-08-08 13:32:27 +03:00
|
|
|
|
2024-08-08 16:38:54 +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>";
|
2024-08-08 16:38:54 +03:00
|
|
|
print_r($contingent);
|
2024-08-08 13:32:27 +03:00
|
|
|
echo "</pre>";
|