diff --git a/.gitignore b/.gitignore index 3649080..2749dec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/public/img/icons/play-button.png /.phpunit.cache /node_modules /public/build @@ -21,3 +22,4 @@ yarn-error.log /.phpstorm.meta.php /_ide_helper.php /_ide_helper_models.php +/public/img/icons/play-button.png diff --git a/app/Services/PageScrapper.php b/app/Services/PageScrapper.php index 956cfb1..46b4880 100644 --- a/app/Services/PageScrapper.php +++ b/app/Services/PageScrapper.php @@ -2,6 +2,9 @@ namespace App\Services; +use DiDom\Document; + +/* class PageScrapper { private string $url; @@ -22,7 +25,7 @@ class PageScrapper $arr = []; $rez = preg_match_all($strForPregMatch, $page, $arr); - return $content = $arr[1][0]; + return $content = $arr[0][0]; } public function normalizeURLFile($content) @@ -60,3 +63,72 @@ class PageScrapper return $content; } } +*/ + +class PageScrapper +{ + private string $url; + private string $contentMarker; + + public function __construct($url, $contentMarker) + { + $this->url = $url; + $this->contentMarker = $contentMarker; + $this->document = new Document($this->url, true); + } + public function getFullHTML() + { + return $this->document; + } + public function printHTML() + { + $rez = $this->document; + $content = $rez->first($this->contentMarker)->html(); + return $content; + } + public function normalizePath() + { + $rez = $this->document; + $content = $rez->first($this->contentMarker); + $links = $content->find('a[href]'); + $srclinks = $content->find('img[src]'); + + + $html0 = $content->html(); + foreach ($links as $k => $link) { + $href = $link->attr('href'); + + if (!str_contains($link->attr('href'), "https://")) { + + + $tmp = explode('/', rawurldecode($href)); + foreach ( $tmp as $k => $v) { + $tmp[$k] = rawurlencode($v); + } + $href = implode('/', $tmp); + + + $html0 = str_replace($href, 'https://mkgtu.ru' . $href, $html0); + } + } + foreach ($srclinks as $k => $srclink) { + $src = $srclink->attr('src'); + + if (!str_contains($srclink->attr('src'), "https://")) { + + + $tmp = explode('/', rawurldecode($src)); + foreach ( $tmp as $k => $v) { + $tmp[$k] = rawurlencode($v); + } + $src = implode('/', $tmp); + + + $html0 = str_replace($src, 'https://mkgtu.ru' . $src, $html0); + } + } + str_replace('st yle', 'style', $html0); + + return $html0; + } +} diff --git a/composer.json b/composer.json index 711b14f..4fa8bb7 100644 --- a/composer.json +++ b/composer.json @@ -8,8 +8,9 @@ ], "license": "MIT", "require": { - "php": "^8.2", + "php": "^8.1|8.2", "guzzlehttp/guzzle": "^7.8.1", + "imangazaliev/didom": "^2.0", "laravel/framework": "^10.41.0", "laravel/sanctum": "^3.3.3", "laravel/tinker": "^2.9.0", @@ -64,6 +65,7 @@ } }, "config": { + "platform-check": false, "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true, diff --git a/resources/views/layouts/applicant-layout.blade.php b/resources/views/layouts/applicant-layout.blade.php index cb7e71f..a51ecdc 100644 --- a/resources/views/layouts/applicant-layout.blade.php +++ b/resources/views/layouts/applicant-layout.blade.php @@ -319,9 +319,27 @@ - - + + + + @yield('content') diff --git a/resources/views/menu/abitur/aspirantura.blade.php b/resources/views/menu/abitur/aspirantura.blade.php index aaf63ec..5a70006 100644 --- a/resources/views/menu/abitur/aspirantura.blade.php +++ b/resources/views/menu/abitur/aspirantura.blade.php @@ -1,16 +1,16 @@ @extends('layouts.applicant-layout') + @section('content') -
Для поступающих на обучение по программам аспирантуры
-
+
Онлайн-консультации для поступающих и родителей
+
@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/aspirantura/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); - echo $content; + $PageScrapper = new PageScrapper("https://www.mkgtu.ru/postuplenie/web-consultations/",".content_info"); + + $content = $PageScrapper->normalizePath(); + echo $content; @endphp diff --git a/resources/views/menu/abitur/kolledzh.blade.php b/resources/views/menu/abitur/kolledzh.blade.php index 6d5abe4..f4cb46b 100644 --- a/resources/views/menu/abitur/kolledzh.blade.php +++ b/resources/views/menu/abitur/kolledzh.blade.php @@ -6,11 +6,10 @@
@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/kolledzh/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); - echo $content; + $PageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/kolledzh/",".content_info"); + + $content = $PageScrapper->normalizePath(); + echo $content; @endphp diff --git a/resources/views/menu/abitur/ordinatura.blade.php b/resources/views/menu/abitur/ordinatura.blade.php index 62e14da..7b8cd43 100644 --- a/resources/views/menu/abitur/ordinatura.blade.php +++ b/resources/views/menu/abitur/ordinatura.blade.php @@ -6,12 +6,9 @@
@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/ordinatura/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); + $PageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/ordinatura/",".content_info"); + $content = $PageScrapper->normalizePath(); echo $content; - @endphp
diff --git a/resources/views/menu/abitur/platnye-obrazovatelnye-uslugi.blade.php b/resources/views/menu/abitur/platnye-obrazovatelnye-uslugi.blade.php index 786c3ad..66d5603 100644 --- a/resources/views/menu/abitur/platnye-obrazovatelnye-uslugi.blade.php +++ b/resources/views/menu/abitur/platnye-obrazovatelnye-uslugi.blade.php @@ -6,10 +6,8 @@
@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/platnye-obrazovatelnye-uslugi/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); + $PageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/platnye-obrazovatelnye-uslugi/",".content_info"); + $content = $PageScrapper->normalizePath(); echo $content; @endphp diff --git a/resources/views/menu/abitur/spetsialitet-magistratura.blade.php b/resources/views/menu/abitur/spetsialitet-magistratura.blade.php index 289827f..e4f6f51 100644 --- a/resources/views/menu/abitur/spetsialitet-magistratura.blade.php +++ b/resources/views/menu/abitur/spetsialitet-magistratura.blade.php @@ -6,11 +6,9 @@
@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); - echo $content ; + $PageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/",".content_info"); + $content = $PageScrapper->normalizePath(); + echo $content; @endphp diff --git a/resources/views/menu/abitur/videomaterialy-dlya-postupayushchikh.blade.php b/resources/views/menu/abitur/videomaterialy-dlya-postupayushchikh.blade.php index f2fa0c8..d65f716 100644 --- a/resources/views/menu/abitur/videomaterialy-dlya-postupayushchikh.blade.php +++ b/resources/views/menu/abitur/videomaterialy-dlya-postupayushchikh.blade.php @@ -6,16 +6,9 @@
@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/videomaterialy-dlya-postupayushchikh/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); - -// $content = str_replace( -// 'Обложка Госуслуги_page-0001.jpg', -// 'Обложка Госуслуги_page-0001.jpg', -// $content); - echo $content; + $PageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/videomaterialy-dlya-postupayushchikh/",".content_info"); + $content = $PageScrapper->normalizePath(); + echo $content; @endphp diff --git a/resources/views/menu/abitur/web-consultations.blade.php b/resources/views/menu/abitur/web-consultations.blade.php index bffdc34..8662e5c 100644 --- a/resources/views/menu/abitur/web-consultations.blade.php +++ b/resources/views/menu/abitur/web-consultations.blade.php @@ -4,15 +4,13 @@
-@php - use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://www.mkgtu.ru/postuplenie/web-consultations/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); - echo $content; + @php + use App\Services\PageScrapper; + $PageScrapper = new PageScrapper("https://www.mkgtu.ru/postuplenie/web-consultations/",".content_info"); + $content = $PageScrapper->normalizePath(); + echo $content; - @endphp + @endphp
diff --git a/resources/views/menu/course.blade.php b/resources/views/menu/course.blade.php index df990a3..43ad193 100644 --- a/resources/views/menu/course.blade.php +++ b/resources/views/menu/course.blade.php @@ -1,4 +1,5 @@ @extends('layouts.applicant-layout') + @section('content')
Международная деятельность
-
+
@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/inostrannym-abiturientam/mezhdunarodnaya-deyatelnost/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); - echo $content; + $PageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/inostrannym-abiturientam/mezhdunarodnaya-deyatelnost/",".content_info"); + $content = $PageScrapper->printHTML(); + $content = $PageScrapper->normalizePath(); + echo $content; @endphp
@endsection + diff --git a/resources/views/menu/inostrannym-abiturientam/obshchie-svedeniya.blade.php b/resources/views/menu/inostrannym-abiturientam/obshchie-svedeniya.blade.php index 2d26872..70787ce 100644 --- a/resources/views/menu/inostrannym-abiturientam/obshchie-svedeniya.blade.php +++ b/resources/views/menu/inostrannym-abiturientam/obshchie-svedeniya.blade.php @@ -1,19 +1,25 @@ @extends('layouts.applicant-layout') @section('content') +
Общие сведения
-
+
@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/inostrannym-abiturientam/obshchie-svedeniya/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); - echo $content; + $PageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/inostrannym-abiturientam/obshchie-svedeniya/",".content_info"); + $content = $PageScrapper->printHTML(); + $content = $PageScrapper->normalizePath(); + echo $content; @endphp
@endsection + + diff --git a/resources/views/menu/inostrannym-abiturientam/tsentr-mezhdunarodnogo-obrazovaniya.blade.php b/resources/views/menu/inostrannym-abiturientam/tsentr-mezhdunarodnogo-obrazovaniya.blade.php index 74b6529..8022cf4 100644 --- a/resources/views/menu/inostrannym-abiturientam/tsentr-mezhdunarodnogo-obrazovaniya.blade.php +++ b/resources/views/menu/inostrannym-abiturientam/tsentr-mezhdunarodnogo-obrazovaniya.blade.php @@ -1,16 +1,16 @@ @extends('layouts.applicant-layout') @section('content') +
Центр Международного образования
@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/inostrannym-abiturientam/tsentr-mezhdunarodnogo-obrazovaniya/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); - echo $content; + $PageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/inostrannym-abiturientam/tsentr-mezhdunarodnogo-obrazovaniya/",".content_info"); + $content = $PageScrapper->printHTML(); + $content = $PageScrapper->normalizePath(); + echo $content; @endphp diff --git a/resources/views/menu/olimpiady-dlya-shkolnikov.blade.php b/resources/views/menu/olimpiady-dlya-shkolnikov.blade.php index 017051d..3006fb0 100644 --- a/resources/views/menu/olimpiady-dlya-shkolnikov.blade.php +++ b/resources/views/menu/olimpiady-dlya-shkolnikov.blade.php @@ -1,5 +1,8 @@ @extends('layouts.applicant-layout') + @section('content') + +
Олимпиады для школьников
{{-- пофиксить!!!!--}}
@@ -7,20 +10,9 @@
@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/olimpiady-dlya-shkolnikov/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); - -// $tmp = preg_match_all('/

/isU', "https://mkgtu.ru/postuplenie/olimpiady-dlya-shkolnikov/", $arr); -// -// $arr[0] = array_unique($arr[0]); -// $str = $arr[0][0]; - $content = str_replace('

', '

', $content); - - - - + $PageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/olimpiady-dlya-shkolnikov/",".content_info"); + $content = $PageScrapper->printHTML(); + $content = $PageScrapper->normalizePath(); echo $content; @endphp diff --git a/resources/views/menu/paid_edu.blade.php b/resources/views/menu/paid_edu.blade.php index 6f89bce..c0db6ae 100644 --- a/resources/views/menu/paid_edu.blade.php +++ b/resources/views/menu/paid_edu.blade.php @@ -5,7 +5,7 @@ - + @endsection @section('content') @@ -15,10 +15,9 @@

@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/sveden/paid_edu/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); + $PageScrapper = new PageScrapper("https://mkgtu.ru/sveden/paid_edu/",".content_info"); + $content = $PageScrapper->printHTML(); + $content = $PageScrapper->normalizePath(); echo $content; @endphp diff --git a/resources/views/menu/podgotovitelnye-kursy.blade.php b/resources/views/menu/podgotovitelnye-kursy.blade.php index 03ada84..1f6924b 100644 --- a/resources/views/menu/podgotovitelnye-kursy.blade.php +++ b/resources/views/menu/podgotovitelnye-kursy.blade.php @@ -2,15 +2,14 @@ @section('content')
Подготовительные курсы
-
+
@php - use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/podgotovitelnye-kursy/", '
'); - $row = $pageScrapper->getHTML(); - $content = $pageScrapper->normalizeURLFile($row); - $content = $pageScrapper->cutHTML($content,'//isU'); + use App\Services\PageScrapper; + $PageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/podgotovitelnye-kursy/",".content_info"); + $content = $PageScrapper->printHTML(); + $content = $PageScrapper->normalizePath(); echo $content; @endphp