diff --git a/app/Services/PageScrapper.php b/app/Services/PageScrapper.php new file mode 100644 index 0000000..ac858df --- /dev/null +++ b/app/Services/PageScrapper.php @@ -0,0 +1,59 @@ +') + { + $this->url = $url; + $this->contentMarker = $contentMarker; + } + + 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("
'.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/resources/views/menu/abitur/web-consultations.blade.php b/resources/views/menu/abitur/web-consultations.blade.php index 4edd57c..efaa0a8 100644 --- a/resources/views/menu/abitur/web-consultations.blade.php +++ b/resources/views/menu/abitur/web-consultations.blade.php @@ -3,34 +3,16 @@
'.print_r($arr[1]).''; +
'.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].'