From bfcb9cdba2d80724df13fcdd60274a739141b303 Mon Sep 17 00:00:00 2001 From: Holiienko Roman Date: Tue, 23 Jan 2024 15:45:52 +0300 Subject: [PATCH 1/4] adding new page --- app/Services/PageScrapper.php | 17 ++++++++---- resources/views/menu/abitur.blade.php | 2 +- .../spetsialitet-magistratura.blade.php | 26 +++++++++++++++++++ resources/views/menu/course.blade.php | 2 +- routes/web.php | 4 +++ 5 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 resources/views/menu/abitur/spetsialitet-magistratura.blade.php diff --git a/app/Services/PageScrapper.php b/app/Services/PageScrapper.php index bd86bad..20e0e33 100644 --- a/app/Services/PageScrapper.php +++ b/app/Services/PageScrapper.php @@ -15,22 +15,29 @@ class PageScrapper public function getHTML() { + $page = file_get_contents($this->url); - $strForPregMatch = "/" . "{$this->contentMarker}" . "(.*)<\/div>/isU"; + $strForPregMatch = "/" . "{$this->contentMarker}" . "(.*)<\/div>/is"; + $arr = []; $rez = preg_match_all($strForPregMatch, $page, $arr); - return $content = $arr[1][0].''; + + return $content = $arr[1][0]; + } public function normalizeURLFile($content) { - $rez = preg_match_all('/href="(.*)"/isU',$content,$arr); + //$content = preg_replace('//isU',$content,$arr); foreach ($arr[1] as $el) { - if (strpos($el, 'http') !== 0) { - $content = str_replace($el,'https://mkgtu.ru'.$el,$content); + if (!str_contains($el, 'https://')){ + $content = str_replace($el,'https://mkgtu.ru' . $el,$content); + } } return $content; + } } diff --git a/resources/views/menu/abitur.blade.php b/resources/views/menu/abitur.blade.php index f319136..461dfee 100644 --- a/resources/views/menu/abitur.blade.php +++ b/resources/views/menu/abitur.blade.php @@ -38,7 +38,7 @@
- +

diff --git a/resources/views/menu/abitur/spetsialitet-magistratura.blade.php b/resources/views/menu/abitur/spetsialitet-magistratura.blade.php new file mode 100644 index 0000000..9431d51 --- /dev/null +++ b/resources/views/menu/abitur/spetsialitet-magistratura.blade.php @@ -0,0 +1,26 @@ +@extends('layouts.applicant-layout') +@section('content') +
Для поступающих на программы бакалавриата, магистратуры
+
+ +
+ @php + use App\Services\PageScrapper; + $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/", '
'); + $row = $pageScrapper->getHTML(); + $content = $pageScrapper->normalizeURLFile($row); + + + + $page = "https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/"; + $strForScissors = '//isU'; + $tmp = preg_match_all($strForScissors, $content, $arr); + $content = str_replace($arr[1],'',$content); + + echo $content ; + + @endphp + +
+
+@endsection diff --git a/resources/views/menu/course.blade.php b/resources/views/menu/course.blade.php index 05fdcd0..9a98c14 100644 --- a/resources/views/menu/course.blade.php +++ b/resources/views/menu/course.blade.php @@ -36,7 +36,7 @@
@php use App\Services\PageScrapper; - $pageScrapper = new PageScrapper("https://www.mkgtu.ru/postuplenie/web-consultations/", '
'); + $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/podat-dokumenty-onlayn/", '
'); $row = $pageScrapper->getHTML(); $content = $pageScrapper->normalizeURLFile($row); echo $content; diff --git a/routes/web.php b/routes/web.php index 7592924..84b05f6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -38,6 +38,10 @@ Route::get('/web-consultations', function () { return view('menu.abitur.web-consultations'); })->name('web-consultations'); +Route::get('/spetsialitet-magistratura', function () { + return view('menu.abitur.spetsialitet-magistratura'); +})->name('spetsialitet-magistratura'); + Route::post('/uploadfile', [UploadFileController::class, 'showUploadFile'])->name('uploadfile'); Route::get('/dashboard', function () { From f8155f2557320dcdc482abbd1b11e818fca460f0 Mon Sep 17 00:00:00 2001 From: Holiienko Roman Date: Tue, 23 Jan 2024 15:50:36 +0300 Subject: [PATCH 2/4] fixing previous commit --- resources/views/menu/abitur/web-consultations.blade.php | 4 ++++ resources/views/menu/course.blade.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/resources/views/menu/abitur/web-consultations.blade.php b/resources/views/menu/abitur/web-consultations.blade.php index efaa0a8..2365629 100644 --- a/resources/views/menu/abitur/web-consultations.blade.php +++ b/resources/views/menu/abitur/web-consultations.blade.php @@ -9,6 +9,10 @@ $pageScrapper = new PageScrapper("https://www.mkgtu.ru/postuplenie/web-consultations/", '
'); $row = $pageScrapper->getHTML(); $content = $pageScrapper->normalizeURLFile($row); + $page = "https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/"; + $strForScissors = '//isU'; + $tmp = preg_match_all($strForScissors, $content, $arr); + $content = str_replace($arr[1],'',$content); echo $content; @endphp diff --git a/resources/views/menu/course.blade.php b/resources/views/menu/course.blade.php index 9a98c14..9fa261d 100644 --- a/resources/views/menu/course.blade.php +++ b/resources/views/menu/course.blade.php @@ -39,6 +39,10 @@ $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/podat-dokumenty-onlayn/", '
'); $row = $pageScrapper->getHTML(); $content = $pageScrapper->normalizeURLFile($row); + $page = "https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/"; + $strForScissors = '//isU'; + $tmp = preg_match_all($strForScissors, $content, $arr); + $content = str_replace($arr[1],'',$content); echo $content; @endphp From 05fbca2353b1bd8563c5653271735a7d96780438 Mon Sep 17 00:00:00 2001 From: Holiienko Roman Date: Wed, 24 Jan 2024 13:30:27 +0300 Subject: [PATCH 3/4] adding new method to PageScrapper, adding new page --- app/Services/PageScrapper.php | 22 ++++++++++++++----- resources/views/menu/abitur.blade.php | 2 +- .../views/menu/abitur/kolledzh.blade.php | 19 ++++++++++++++++ .../spetsialitet-magistratura.blade.php | 11 ++-------- .../menu/abitur/web-consultations.blade.php | 7 ++---- resources/views/menu/course.blade.php | 7 ++---- routes/web.php | 4 ++++ 7 files changed, 47 insertions(+), 25 deletions(-) create mode 100644 resources/views/menu/abitur/kolledzh.blade.php diff --git a/app/Services/PageScrapper.php b/app/Services/PageScrapper.php index 20e0e33..7c00dc6 100644 --- a/app/Services/PageScrapper.php +++ b/app/Services/PageScrapper.php @@ -29,15 +29,27 @@ class PageScrapper public function normalizeURLFile($content) { - //$content = preg_replace('//isU',$content,$arr); - foreach ($arr[1] as $el) { - if (!str_contains($el, 'https://')){ - $content = str_replace($el,'https://mkgtu.ru' . $el,$content); + $rez = preg_match_all('//isU',$content,$arr); + $arr[1] = array_unique($arr[1]); + foreach ($arr[1] as $el) { + if (!str_starts_with($el, 'https')){ + $content = str_replace($el,'https://mkgtu.ru' . $el,$content); } } return $content; + } + public function cutHTML($content,$strForScissors) + { + + + $arr = []; + $rez = preg_match_all($strForScissors, $content, $arr); + $content = str_replace($arr[1],'',$content); + + return $content; + + } } diff --git a/resources/views/menu/abitur.blade.php b/resources/views/menu/abitur.blade.php index 461dfee..6b8f89c 100644 --- a/resources/views/menu/abitur.blade.php +++ b/resources/views/menu/abitur.blade.php @@ -49,7 +49,7 @@
- +

diff --git a/resources/views/menu/abitur/kolledzh.blade.php b/resources/views/menu/abitur/kolledzh.blade.php new file mode 100644 index 0000000..6d5abe4 --- /dev/null +++ b/resources/views/menu/abitur/kolledzh.blade.php @@ -0,0 +1,19 @@ +@extends('layouts.applicant-layout') +@section('content') +
Для поступающих на обучение по программам среднего профессионального образования
+
+ +
+ @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; + + @endphp + +
+
+@endsection diff --git a/resources/views/menu/abitur/spetsialitet-magistratura.blade.php b/resources/views/menu/abitur/spetsialitet-magistratura.blade.php index 9431d51..289827f 100644 --- a/resources/views/menu/abitur/spetsialitet-magistratura.blade.php +++ b/resources/views/menu/abitur/spetsialitet-magistratura.blade.php @@ -1,6 +1,6 @@ @extends('layouts.applicant-layout') @section('content') -
Для поступающих на программы бакалавриата, магистратуры
+
Для поступающих на программы бакалавриата, магистратуры
@@ -9,14 +9,7 @@ $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/", '
'); $row = $pageScrapper->getHTML(); $content = $pageScrapper->normalizeURLFile($row); - - - - $page = "https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/"; - $strForScissors = '//isU'; - $tmp = preg_match_all($strForScissors, $content, $arr); - $content = str_replace($arr[1],'',$content); - + $content = $pageScrapper->cutHTML($content,'//isU'); echo $content ; @endphp diff --git a/resources/views/menu/abitur/web-consultations.blade.php b/resources/views/menu/abitur/web-consultations.blade.php index 2365629..bffdc34 100644 --- a/resources/views/menu/abitur/web-consultations.blade.php +++ b/resources/views/menu/abitur/web-consultations.blade.php @@ -1,6 +1,6 @@ @extends('layouts.applicant-layout') @section('content') -
Веб-консультации для абитуриентов и их родителей
+
Веб-консультации для абитуриентов и их родителей
@@ -9,10 +9,7 @@ $pageScrapper = new PageScrapper("https://www.mkgtu.ru/postuplenie/web-consultations/", '
'); $row = $pageScrapper->getHTML(); $content = $pageScrapper->normalizeURLFile($row); - $page = "https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/"; - $strForScissors = '//isU'; - $tmp = preg_match_all($strForScissors, $content, $arr); - $content = str_replace($arr[1],'',$content); + $content = $pageScrapper->cutHTML($content,'//isU'); echo $content; @endphp diff --git a/resources/views/menu/course.blade.php b/resources/views/menu/course.blade.php index 9fa261d..df990a3 100644 --- a/resources/views/menu/course.blade.php +++ b/resources/views/menu/course.blade.php @@ -30,7 +30,7 @@ } -
Подача документов онлайн
+
Подача документов онлайн
@@ -39,10 +39,7 @@ $pageScrapper = new PageScrapper("https://mkgtu.ru/postuplenie/podat-dokumenty-onlayn/", '
'); $row = $pageScrapper->getHTML(); $content = $pageScrapper->normalizeURLFile($row); - $page = "https://mkgtu.ru/postuplenie/priemnaya-kampaniya/spetsialitet-magistratura-2022/"; - $strForScissors = '//isU'; - $tmp = preg_match_all($strForScissors, $content, $arr); - $content = str_replace($arr[1],'',$content); + $content = $pageScrapper->cutHTML($content,'//isU'); echo $content; @endphp diff --git a/routes/web.php b/routes/web.php index 84b05f6..12e2918 100644 --- a/routes/web.php +++ b/routes/web.php @@ -42,6 +42,10 @@ Route::get('/spetsialitet-magistratura', function () { return view('menu.abitur.spetsialitet-magistratura'); })->name('spetsialitet-magistratura'); +Route::get('/kolledzh', function () { + return view('menu.abitur.kolledzh'); +})->name('kolledzh'); + Route::post('/uploadfile', [UploadFileController::class, 'showUploadFile'])->name('uploadfile'); Route::get('/dashboard', function () { From dee85023d40516c9432da80f988c8380bfe4571b Mon Sep 17 00:00:00 2001 From: Holiienko Roman Date: Wed, 24 Jan 2024 15:23:23 +0300 Subject: [PATCH 4/4] new pages, renaming routes --- app/Services/PageScrapper.php | 1 + resources/views/home.blade.php | 2 +- resources/views/menu/abitur.blade.php | 12 ++++----- .../views/menu/abitur/aspirantura.blade.php | 19 ++++++++++++++ .../views/menu/abitur/ordinatura.blade.php | 19 ++++++++++++++ .../platnye-obrazovatelnye-uslugi.blade.php | 19 ++++++++++++++ ...omaterialy-dlya-postupayushchikh.blade.php | 25 +++++++++++++++++++ routes/web.php | 24 +++++++++++++++--- 8 files changed, 110 insertions(+), 11 deletions(-) create mode 100644 resources/views/menu/abitur/aspirantura.blade.php create mode 100644 resources/views/menu/abitur/ordinatura.blade.php create mode 100644 resources/views/menu/abitur/platnye-obrazovatelnye-uslugi.blade.php create mode 100644 resources/views/menu/abitur/videomaterialy-dlya-postupayushchikh.blade.php diff --git a/app/Services/PageScrapper.php b/app/Services/PageScrapper.php index 7c00dc6..f52aabe 100644 --- a/app/Services/PageScrapper.php +++ b/app/Services/PageScrapper.php @@ -37,6 +37,7 @@ class PageScrapper $content = str_replace($el,'https://mkgtu.ru' . $el,$content); } } + return $content; } diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 6547279..51c2bf5 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -26,7 +26,7 @@
- +
diff --git a/resources/views/menu/abitur.blade.php b/resources/views/menu/abitur.blade.php index 6b8f89c..05dc9f7 100644 --- a/resources/views/menu/abitur.blade.php +++ b/resources/views/menu/abitur.blade.php @@ -60,7 +60,7 @@
- +

@@ -71,7 +71,7 @@
- +

@@ -82,7 +82,7 @@
- +

@@ -93,7 +93,7 @@
- +

@@ -104,7 +104,7 @@
- +

@@ -115,7 +115,7 @@
- +

diff --git a/resources/views/menu/abitur/aspirantura.blade.php b/resources/views/menu/abitur/aspirantura.blade.php new file mode 100644 index 0000000..aaf63ec --- /dev/null +++ b/resources/views/menu/abitur/aspirantura.blade.php @@ -0,0 +1,19 @@ +@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; + + @endphp + +
+
+@endsection diff --git a/resources/views/menu/abitur/ordinatura.blade.php b/resources/views/menu/abitur/ordinatura.blade.php new file mode 100644 index 0000000..62e14da --- /dev/null +++ b/resources/views/menu/abitur/ordinatura.blade.php @@ -0,0 +1,19 @@ +@extends('layouts.applicant-layout') +@section('content') +
Для поступающих на обучение по программам ординатуры
+
+ +
+ @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'); + echo $content; + + @endphp + +
+
+@endsection diff --git a/resources/views/menu/abitur/platnye-obrazovatelnye-uslugi.blade.php b/resources/views/menu/abitur/platnye-obrazovatelnye-uslugi.blade.php new file mode 100644 index 0000000..786c3ad --- /dev/null +++ b/resources/views/menu/abitur/platnye-obrazovatelnye-uslugi.blade.php @@ -0,0 +1,19 @@ +@extends('layouts.applicant-layout') +@section('content') +
Для поступающих на обучение по договорам об оказании платных образовательных услуг
+
+ +
+ @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'); + echo $content; + + @endphp + +
+
+@endsection diff --git a/resources/views/menu/abitur/videomaterialy-dlya-postupayushchikh.blade.php b/resources/views/menu/abitur/videomaterialy-dlya-postupayushchikh.blade.php new file mode 100644 index 0000000..cd0f407 --- /dev/null +++ b/resources/views/menu/abitur/videomaterialy-dlya-postupayushchikh.blade.php @@ -0,0 +1,25 @@ +@extends('layouts.applicant-layout') +@section('content') +
Видеоматериалы для поступающих
+
+ +
+ @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; + + @endphp + +
+
+@endsection + diff --git a/routes/web.php b/routes/web.php index 12e2918..d78de1f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -30,22 +30,38 @@ Route::get('/course', function () { return view('menu.course'); })->name('course'); -Route::get('/abitur', function () { +Route::get('/applicant', function () { return view('menu.abitur'); -})->name('applicant'); +})->name('abitur'); Route::get('/web-consultations', function () { return view('menu.abitur.web-consultations'); })->name('web-consultations'); -Route::get('/spetsialitet-magistratura', function () { +Route::get('/specialty-magistracy', function () { return view('menu.abitur.spetsialitet-magistratura'); })->name('spetsialitet-magistratura'); -Route::get('/kolledzh', function () { +Route::get('/college', function () { return view('menu.abitur.kolledzh'); })->name('kolledzh'); +Route::get('/paid-educational-services', function () { + return view('menu.abitur.platnye-obrazovatelnye-uslugi'); +})->name('platnye-obrazovatelnye-uslugi'); + +Route::get('/residency', function () { + return view('menu.abitur.ordinatura'); +})->name('ordinatura'); + +Route::get('/traineeship', function () { + return view('menu.abitur.aspirantura'); +})->name('aspirantura'); + +Route::get('/video-materials-for-applicants', function () { + return view('menu.abitur.videomaterialy-dlya-postupayushchikh'); +})->name('videomaterialy-dlya-postupayushchikh'); + Route::post('/uploadfile', [UploadFileController::class, 'showUploadFile'])->name('uploadfile'); Route::get('/dashboard', function () {