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') -