From f65fbda4a70c88f78f06db13d81bf0da4d43f5ef Mon Sep 17 00:00:00 2001 From: Holiienko Roman Date: Tue, 23 Jan 2024 11:05:43 +0300 Subject: [PATCH] fixing previous commit --- app/Services/PageScrapper.php | 23 ------ config/auth.php | 2 +- config/database.php | 4 +- config/session.php | 2 +- config/view.php | 2 +- resources/views/menu/course.blade.php | 105 ++------------------------ 6 files changed, 13 insertions(+), 125 deletions(-) diff --git a/app/Services/PageScrapper.php b/app/Services/PageScrapper.php index ac858df..bd86bad 100644 --- a/app/Services/PageScrapper.php +++ b/app/Services/PageScrapper.php @@ -15,45 +15,22 @@ class PageScrapper public function getHTML() { -// echo($this->url); -// echo($this->contentMarker); $page = file_get_contents($this->url); $strForPregMatch = "/" . "{$this->contentMarker}" . "(.*)<\/div>/isU"; $arr = []; $rez = preg_match_all($strForPregMatch, $page, $arr); - //echo '
'.print_r($arr[1]).'
'; - - - //$tmp = explode("
" , $page); - //$content = $tmp[4].$tmp[5].$tmp[6]; - - - - return $content = $arr[1][0].''; } public function normalizeURLFile($content) { - - $rez = preg_match_all('/href="(.*)"/isU',$content,$arr); - //echo '
'.print_r($arr,1).'
'; foreach ($arr[1] as $el) { - //if (strpos($el, '/abitur') !== false) { if (strpos($el, 'http') !== 0) { - //str_replace('/abitur', 'https://mkgtu.ru/abitur',$el); $content = str_replace($el,'https://mkgtu.ru'.$el,$content); } } - //$content = $arr[1][0].''; - //$content = preg_replace('/href="(?!http|#)/is', 'https:\/\/mkgtu.ru', $content, -1, $count); - - //$content = str_replace('href="','href="https://mkgtu.ru',$content); - //$pos = strripos($content,'/abitur'); - //echo substr_replace($content, 'https://mkgtu.ru',$pos,0) - return $content; } } diff --git a/config/auth.php b/config/auth.php index 4fa3d6d..9548c15 100644 --- a/config/auth.php +++ b/config/auth.php @@ -24,7 +24,7 @@ return [ |-------------------------------------------------------------------------- | | Next, you may define every authentication guard for your application. - | Of abitur, a great default configuration has been defined for you + | Of course, a great default configuration has been defined for you | here which uses session storage and the Eloquent user provider. | | All authentication drivers have a user provider. This defines how the diff --git a/config/database.php b/config/database.php index 580947f..137ad18 100644 --- a/config/database.php +++ b/config/database.php @@ -10,7 +10,7 @@ return [ |-------------------------------------------------------------------------- | | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of abitur + | to use as your default connection for all database work. Of course | you may use many connections at once using the Database library. | */ @@ -23,7 +23,7 @@ return [ |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. - | Of abitur, examples of configuring each database platform that is + | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | diff --git a/config/session.php b/config/session.php index 2698d3d..e738cb3 100644 --- a/config/session.php +++ b/config/session.php @@ -80,7 +80,7 @@ return [ |-------------------------------------------------------------------------- | | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of abitur, a sensible default is + | should use to manage the sessions. Of course, a sensible default is | provided for you; however, you are free to change this as needed. | */ diff --git a/config/view.php b/config/view.php index 4942d72..22b8a18 100644 --- a/config/view.php +++ b/config/view.php @@ -8,7 +8,7 @@ return [ |-------------------------------------------------------------------------- | | Most templating systems load templates from disk. Here you may specify - | an array of paths that should be checked for your views. Of abitur + | an array of paths that should be checked for your views. Of course | the usual Laravel view path has already been registered for you. | */ diff --git a/resources/views/menu/course.blade.php b/resources/views/menu/course.blade.php index af7c928..05fdcd0 100644 --- a/resources/views/menu/course.blade.php +++ b/resources/views/menu/course.blade.php @@ -29,109 +29,20 @@ background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg width='16' height='16' xmlns='http://www.w3.org/2000/svg' fill='%230c63e4'%3e%3cg%3e%3ctitle%3eLayer 1%3c/title%3e%3cpath fill='%23396849' fill-rule='evenodd' d='m1.646,4.646a0.5,0.5 0 0 1 0.708,0l5.646,5.647l5.646,-5.647a0.5,0.5 0 0 1 0.708,0.708l-6,6a0.5,0.5 0 0 1 -0.708,0l-6,-6a0.5,0.5 0 0 1 0,-0.708z' id='svg_1'/%3e%3c/g%3e%3c/svg%3e"); } - - - - - -
Подача документов онлайн
-
(.*)<\/div>/isU',$page,$arr); - //echo '
'.print_r($arr[1]).'
'; +
+ @php + use App\Services\PageScrapper; + $pageScrapper = new PageScrapper("https://www.mkgtu.ru/postuplenie/web-consultations/", '
'); + $row = $pageScrapper->getHTML(); + $content = $pageScrapper->normalizeURLFile($row); + echo $content; + @endphp - //$tmp = explode("
" , $page); - //$content = $tmp[4].$tmp[5].$tmp[6]; - - $content = $arr[1][0].'
'; - $rez = preg_match_all('/href="(.*)"/isU',$content,$arr); - //echo '
'.print_r($arr,1).'
'; - foreach ($arr[1] as $el) { - //if (strpos($el, '/abitur') !== false) { - if (strpos($el, 'http') !== 0) { - //str_replace('/abitur', 'https://mkgtu.ru/abitur',$el); - $content = str_replace($el,'https://mkgtu.ru'.$el,$content); - } - } - //$content = $arr[1][0].'
'; - //$content = preg_replace('/href="(?!http|#)/is', 'https:\/\/mkgtu.ru', $content, -1, $count); - - //$content = str_replace('href="','href="https://mkgtu.ru',$content); - //$pos = strripos($content,'/abitur'); - //echo substr_replace($content, 'https://mkgtu.ru',$pos,0) - - echo $content; - ?>