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 () {