внёс первые изменения
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use SvedenParser\Color;
|
||||
use SvedenParser\ContingentParser\ContingentManager;
|
||||
use SvedenParser\ContingentParser\ContingentRepository;
|
||||
use SvedenParser\Parser\ContingentManager;
|
||||
use SvedenParser\Parser\ContingentRepository;
|
||||
use SvedenParser\Printer;
|
||||
use SvedenParser\Repository;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
@ -11,37 +11,29 @@ define('SVEDEN_PARSER', '/home/developer/sveden_parser');
|
||||
|
||||
require_once SVEDEN_PARSER . "/vendor/autoload.php";
|
||||
|
||||
if (file_exists(Repository::FILE_ADD_RECORDING)) {
|
||||
Printer::println("Обнаружен файл " . Repository::FILE_ADD_RECORDING, Color::RED);
|
||||
Printer::print("Продолжить y/n? ", Color::BLUE);
|
||||
$action = trim(fgets(STDIN));
|
||||
if ($action !== 'y') {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$manager = new ContingentManager();
|
||||
// $sites = $manager->getSitesFromLog('sites-http.log');
|
||||
$sites = $manager->getSites();
|
||||
// $sites = Yaml::parse(file_get_contents(dirname(__FILE__) ."/sites.yaml"));
|
||||
|
||||
$start = 0; $end = count($sites);
|
||||
// $start = 0; $end = (int)(count($sites) / 2);
|
||||
// $start = (int)(count($sites) / 2); $end = count($sites);
|
||||
|
||||
for ($i = $start; $i < $end; $i++) {
|
||||
Printer::print(++$i . ". ", Color::GREEN);
|
||||
$manager->collectData($sites[--$i]);
|
||||
}
|
||||
Printer::println();
|
||||
|
||||
try {
|
||||
if (!file_exists(Repository::FILE_ADD_RECORDING)) {
|
||||
throw new Exception(
|
||||
"Файл " . Repository::FILE_ADD_RECORDING
|
||||
. " не обнаружен. Дозапись в базу не требуется"
|
||||
);
|
||||
}
|
||||
|
||||
$contingent = Yaml::parse(
|
||||
file_get_contents(SVEDEN_PARSER . '/' . Repository::FILE_ADD_RECORDING)
|
||||
);
|
||||
$databaseFacade = new ContingentRepository();
|
||||
$databaseFacade->insert($contingent);
|
||||
|
||||
Printer::println("Дозапись выполнена!", Color::BLUE);
|
||||
} catch (\Exception $e) {
|
||||
Printer::println($e->getMessage(), Color::RED);
|
||||
exit(0);
|
||||
}
|
||||
if (!file_exists(Repository::FILE_ADD_RECORDING)) {
|
||||
Printer::println("Файл " . Repository::FILE_ADD_RECORDING . " не обнаружен. Дозапись в базу не требуется");
|
||||
exit;
|
||||
}
|
||||
$contingent = Yaml::parse(file_get_contents(SVEDEN_PARSER . '/' . Repository::FILE_ADD_RECORDING));
|
||||
(new ContingentRepository())->insert($contingent);
|
||||
Printer::println("Дозапись выполнена!", Color::BLUE);
|
||||
|
19
scripts/convert_log_yaml.php
Normal file
19
scripts/convert_log_yaml.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
define('SVEDEN_PARSER', '/home/developer/sveden_parser');
|
||||
|
||||
require_once SVEDEN_PARSER . "/vendor/autoload.php";
|
||||
$filePath = SVEDEN_PARSER . "/data/doc.yaml";
|
||||
$file = file($filePath);
|
||||
|
||||
$sites = [];
|
||||
foreach ($file as $line) {
|
||||
$site = explode(' ', $line);
|
||||
$sites[] = [
|
||||
'org_id' => (int)$site[0],
|
||||
'site' => trim($site[1]),
|
||||
];
|
||||
}
|
||||
|
||||
$yaml = Yaml::dump($sites);
|
||||
file_put_contents($filePath, $yaml);
|
28
scripts/counter.php
Normal file
28
scripts/counter.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
use SvedenParser\Color;
|
||||
use SvedenParser\PriemParser\PriemManager;
|
||||
use SvedenParser\PriemParser\PriemRepository;
|
||||
use SvedenParser\Printer;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
define('SVEDEN_PARSER', '/home/developer/sveden_parser');
|
||||
|
||||
require_once SVEDEN_PARSER . "/vendor/autoload.php";
|
||||
|
||||
$manager = new PriemManager();
|
||||
$allOrg = $manager->getSites();
|
||||
Printer::println("All: " . count($allOrg), Color::GREEN);
|
||||
$inDB = (new PriemRepository())->universities();
|
||||
Printer::println("In DB: " . count($inDB), Color::GREEN);
|
||||
$docs = Yaml::parse(file_get_contents(SVEDEN_PARSER . "/data/doc.yaml"));
|
||||
Printer::println("Docs: " . count($docs), Color::GREEN);
|
||||
$remains = array_values(array_filter($allOrg, function($var) {
|
||||
global $inDB, $docs;
|
||||
return !in_array($var['org_id'], array_merge($inDB, array_column($docs, 'org_id')));
|
||||
}));
|
||||
Printer::println("Remains: " . count($remains), Color::RED);
|
||||
print_r($remains);
|
||||
|
||||
$yaml = Yaml::dump($remains);
|
||||
file_put_contents(SVEDEN_PARSER . "/data/remains.yaml", $yaml);
|
||||
|
54
scripts/employees_parser.php
Normal file
54
scripts/employees_parser.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
use SvedenParser\Color;
|
||||
use SvedenParser\Parser\EmployeesManager;
|
||||
use SvedenParser\Parser\EmployeesRepository;
|
||||
use SvedenParser\Exception\HtmlException;
|
||||
use SvedenParser\Printer;
|
||||
use SvedenParser\Repository;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
define('SVEDEN_PARSER', '/home/developer/sveden_parser');
|
||||
|
||||
require_once SVEDEN_PARSER . "/vendor/autoload.php";
|
||||
|
||||
if (file_exists(Repository::FILE_ADD_RECORDING)) {
|
||||
Printer::println("Обнаружен файл " . Repository::FILE_ADD_RECORDING, Color::RED);
|
||||
Printer::print("Продолжить y/n? ", Color::BLUE);
|
||||
$action = trim(fgets(STDIN));
|
||||
if ($action !== 'y') {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$manager = new EmployeesManager();
|
||||
$sites = $manager->getSites();
|
||||
// $sites = Yaml::parse(file_get_contents(SVEDEN_PARSER . "/data/remains.yaml"));
|
||||
|
||||
$start = 0; $end = count($sites);
|
||||
|
||||
for ($i = $start; $i < $end; $i++) {
|
||||
try {
|
||||
Printer::print(++$i . ". ", Color::GREEN);
|
||||
$manager->collectData($sites[--$i]);
|
||||
} catch (HtmlException $e) {
|
||||
$e->write($sites[$i]);
|
||||
file_put_contents(SVEDEN_PARSER . '/log/doc.log', implode(' ', $sites[$i]) . PHP_EOL, FILE_APPEND);
|
||||
} catch (\Exception $e) {
|
||||
Printer::println($e->getMessage(), Color::RED);
|
||||
}
|
||||
}
|
||||
Printer::println();
|
||||
|
||||
try {
|
||||
if (!file_exists(Repository::FILE_ADD_RECORDING)) {
|
||||
throw new Exception("Файл " . Repository::FILE_ADD_RECORDING . " не обнаружен. Дозапись в базу не требуется");
|
||||
}
|
||||
|
||||
$employees = Yaml::parse(file_get_contents(Repository::FILE_ADD_RECORDING));
|
||||
$repository = new EmployeesRepository();
|
||||
$repository->insert($employees);
|
||||
|
||||
Printer::println("Дозапись выполнена!", Color::BLUE);
|
||||
} catch (\Exception $e) {
|
||||
Printer::println($e->getMessage(), Color::RED);
|
||||
}
|
@ -1,46 +1,54 @@
|
||||
<?php
|
||||
use SvedenParser\Color;
|
||||
use SvedenParser\Exception\HtmlException;
|
||||
use SvedenParser\PriemParser\PriemManager;
|
||||
use SvedenParser\PriemParser\PriemRepository;
|
||||
use SvedenParser\Printer;
|
||||
use SvedenParser\Repository;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
|
||||
define('SVEDEN_PARSER', '/home/developer/sveden_parser');
|
||||
|
||||
require_once SVEDEN_PARSER . "/vendor/autoload.php";
|
||||
|
||||
if (file_exists(Repository::FILE_ADD_RECORDING)) {
|
||||
Printer::println("Обнаружен файл " . Repository::FILE_ADD_RECORDING, Color::RED);
|
||||
Printer::print("Продолжить y/n? ", Color::BLUE);
|
||||
$action = trim(fgets(STDIN));
|
||||
if ($action !== 'y') {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$manager = new PriemManager();
|
||||
$sites = $manager->getSites();
|
||||
// $sites = Yaml::parse(file_get_contents(dirname(__FILE__) ."/sites.yaml"));
|
||||
// $sites = $manager->getSites();
|
||||
// $sites = Yaml::parse(file_get_contents(SVEDEN_PARSER . "/data/remains.yaml"));
|
||||
|
||||
$start = 0; $end = count($sites);
|
||||
// $start = 0; $end = (int)(count($sites) / 2);
|
||||
// $start = (int)(count($sites) / 2); $end = count($sites);
|
||||
|
||||
for ($i = $start; $i < $end; $i++) {
|
||||
Printer::print(++$i . ". ", Color::GREEN);
|
||||
$manager->collectData($sites[--$i]);
|
||||
try {
|
||||
Printer::print(++$i . ". ", Color::GREEN);
|
||||
$manager->collectData($sites[--$i]);
|
||||
} catch (HtmlException $e) {
|
||||
$e->write($sites[$i]);
|
||||
file_put_contents(SVEDEN_PARSER . '/log/doc.log', implode(' ', $sites[$i]) . PHP_EOL, FILE_APPEND);
|
||||
} catch (\Exception $e) {
|
||||
Printer::println($e->getMessage(), Color::RED);
|
||||
}
|
||||
}
|
||||
Printer::println();
|
||||
|
||||
try {
|
||||
if (!file_exists(Repository::FILE_ADD_RECORDING)) {
|
||||
throw new Exception(
|
||||
"Файл " . Repository::FILE_ADD_RECORDING
|
||||
. " не обнаружен. Дозапись в базу не требуется"
|
||||
);
|
||||
throw new Exception("Файл " . Repository::FILE_ADD_RECORDING . " не обнаружен. Дозапись в базу не требуется");
|
||||
}
|
||||
|
||||
$priem = Yaml::parse(
|
||||
file_get_contents(SVEDEN_PARSER . '/' . Repository::FILE_ADD_RECORDING)
|
||||
);
|
||||
$databaseFacade = new PriemRepository();
|
||||
$databaseFacade->insert($priem);
|
||||
$priem = Yaml::parse(file_get_contents(Repository::FILE_ADD_RECORDING));
|
||||
$repository = new PriemRepository();
|
||||
$repository->insert($priem);
|
||||
|
||||
Printer::println("Дозапись выполнена!", Color::BLUE);
|
||||
Printer::println("Дозапись выполнена!", Color::BLUE);
|
||||
} catch (\Exception $e) {
|
||||
Printer::println($e->getMessage(), Color::RED);
|
||||
exit(0);
|
||||
}
|
116
scripts/test.php
Normal file
116
scripts/test.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
use SvedenParser\Color;
|
||||
use SvedenParser\Parser\ContingentRepository;
|
||||
use SvedenParser\Printer;
|
||||
|
||||
define('SVEDEN_PARSER', '/home/developer/sveden_parser');
|
||||
|
||||
require_once SVEDEN_PARSER . "/vendor/autoload.php";
|
||||
|
||||
// $rep = new ContingentRepository();
|
||||
// // print_r($rep->getHashs(410));
|
||||
// echo $rep->getCountRecords() . PHP_EOL;
|
||||
|
||||
$dataInBase = [
|
||||
[
|
||||
'spec_code' => '09.03.03',
|
||||
'spec_name' => 'Прикладная информатика',
|
||||
'edu_level' => 'Высшее образование - бакалавриат',
|
||||
'edu_forms' => 'Очная',
|
||||
'contingent' => 25,
|
||||
'spec_id' => 3228,
|
||||
'org_id' => 61297,
|
||||
'is_actual' => 1,
|
||||
'change_date' => '2024-10-25 10:10:10',
|
||||
],
|
||||
[
|
||||
'spec_code' => '09.03.03',
|
||||
'spec_name' => 'Прикладная информатика',
|
||||
'edu_level' => 'Высшее образование - бакалавриат',
|
||||
'edu_forms' => 'Очная',
|
||||
'contingent' => 21,
|
||||
'spec_id' => 3228,
|
||||
'org_id' => 61297,
|
||||
'is_actual' => 1,
|
||||
'change_date' => '2024-10-25 10:10:10',
|
||||
],
|
||||
];
|
||||
// Printer::println("DATABASE", Color::GREEN);
|
||||
Printer::print_r($dataInBase, Color::GREEN);
|
||||
|
||||
$hashsMD5 = [];
|
||||
|
||||
|
||||
array_multisort($dataInBase);
|
||||
print_r($dataInBase);
|
||||
exit;
|
||||
foreach ($dataInBase as &$con) {
|
||||
|
||||
|
||||
}
|
||||
// echo 'HASHS' . PHP_EOL;
|
||||
// print_r($hashsMD5);
|
||||
|
||||
$dataInSite = [
|
||||
[
|
||||
'spec_code' => '09.03.03',
|
||||
'spec_name' => 'Прикладная информатика',
|
||||
'edu_level' => 'Высшее образование - бакалавриат',
|
||||
'edu_forms' => 'Очная',
|
||||
'contingent' => 26,
|
||||
'spec_id' => 3228,
|
||||
'org_id' => 61297,
|
||||
],
|
||||
[
|
||||
'spec_code' => '09.03.04',
|
||||
'spec_name' => 'Программная инженерия',
|
||||
'edu_level' => 'Высшее образование - бакалавриат',
|
||||
'edu_forms' => 'Очная',
|
||||
'contingent' => 51,
|
||||
'spec_id' => 3229,
|
||||
'org_id' => 61297,
|
||||
],
|
||||
[
|
||||
'spec_code' => '09.03.01',
|
||||
'spec_name' => 'Информатика и вычислительная техника',
|
||||
'edu_level' => 'Высшее образование - бакалавриат',
|
||||
'edu_forms' => 'Очная',
|
||||
'contingent' => 34,
|
||||
'spec_id' => 3222,
|
||||
'org_id' => 61297,
|
||||
]
|
||||
];
|
||||
Printer::println("VUZ", Color::BLUE);
|
||||
Printer::print_r($dataInSite, Color::BLUE);
|
||||
uasort($dataInSite, fn ($a, $b) => $a['spec_code'] <=> $b['spec_code']);
|
||||
|
||||
Printer::print_r($dataInSite, Color::RED);
|
||||
|
||||
$countDB = count($dataInBase);
|
||||
$string = '';
|
||||
for ($i = 0; $i < count($dataInSite); $i++) {
|
||||
$string .= implode(' ', $dataInSite[$i]);
|
||||
// if (!in_array($hash, array_column($hashsMD5, 'data_hash'))) {
|
||||
// if ($i < $countDB) {
|
||||
// $dataInBase[$i]['is_actual'] = 0;
|
||||
// }
|
||||
// if (!isset($hashsMD5[$i])) {
|
||||
// $hashsMD5[$i] = [
|
||||
// 'org_id' => 61297,
|
||||
// 'sveden_table' => ContingentRepository::TABLE,
|
||||
// 'data_hash' => $hash,
|
||||
// ];
|
||||
// } else {
|
||||
// $hashsMD5[$i]['data_hash'] = $hash;
|
||||
// // }
|
||||
// $dataInSite[$i]['is_actual'] = true;
|
||||
// $dataInSite[$i]['change_date'] = date('Y-m-d H:i:s');
|
||||
// $dataInBase[] = $dataInSite[$i];
|
||||
// }
|
||||
}
|
||||
$hash = md5($string);
|
||||
echo $hash . PHP_EOL;
|
||||
// Printer::println("DATABASE", Color::GREEN);
|
||||
// Printer::print_r($dataInBase, Color::GREEN);
|
||||
// Printer::println("HASHS");
|
||||
// Printer::print_r($hashsMD5);
|
27
scripts/test_client.php
Normal file
27
scripts/test_client.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
use SvedenParser\Parser\ContingentManager;
|
||||
use SvedenParser\Parser\ContingentRepository;
|
||||
use SvedenParser\Parser\ContingentService;
|
||||
use SvedenParser\Http\CurlHelper;
|
||||
use SvedenParser\Http\HttpClient;
|
||||
use SvedenParser\PriemParser\PriemManager;
|
||||
use SvedenParser\PriemParser\PriemParser;
|
||||
|
||||
define('SVEDEN_PARSER', '/home/alexander/Downloads/sveden_parser');
|
||||
|
||||
require_once SVEDEN_PARSER . "/vendor/autoload.php";
|
||||
|
||||
// $client = new HttpClient();
|
||||
// $html = $client->getContentOfSite('http://marsu.ru', [], '/sveden/education');
|
||||
// // $curl = new CurlHelper('https://www.rgiis.ru/sveden/education/', []);
|
||||
// // $html = $curl->getContent();
|
||||
// // echo $html;
|
||||
// $parser = new PriemParser($html);
|
||||
// $data = $parser->getDataTable();
|
||||
|
||||
// (new ContingentService())->getData(html)
|
||||
// print_r($data);
|
||||
// // print_r();
|
||||
// (new ContingentRepository())->save($data);
|
||||
$manager = new ContingentManager();
|
||||
$manager->collectData(['org_id' => 411, 'site' => 'http://marsu.ru']);
|
Reference in New Issue
Block a user