From 94300bee311b9d1b0c2e7c296486aad6b462451d Mon Sep 17 00:00:00 2001 From: aslan Date: Mon, 12 Feb 2024 14:56:24 +0300 Subject: [PATCH] refactoring Service Layer --- app/Services/PageScrapper.php | 86 ++-------------------------------- app/Services/WorkWithFiles.php | 29 ------------ 2 files changed, 4 insertions(+), 111 deletions(-) delete mode 100644 app/Services/WorkWithFiles.php diff --git a/app/Services/PageScrapper.php b/app/Services/PageScrapper.php index bc479ad..7342aaa 100644 --- a/app/Services/PageScrapper.php +++ b/app/Services/PageScrapper.php @@ -4,71 +4,11 @@ namespace App\Services; use DiDom\Document; -/* -class PageScrapper -{ - private string $url; - private string $contentMarker; - - public function __construct($url, $contentMarker = '
') - { - $this->url = $url; - $this->contentMarker = $contentMarker; - } - - public function getHTML() - { - - $page = file_get_contents($this->url); - $strForPregMatch = "/" . "{$this->contentMarker}" . "(.*)<\/div>/is"; - - $arr = []; - $rez = preg_match_all($strForPregMatch, $page, $arr); - - return $content = $arr[0][0]; - } - - public function normalizeURLFile($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); - } - } - $rez = preg_match_all('/src="(.*)">/isU', $content, $arr); - $arr[1] = array_unique($arr[1]); - foreach ($arr[1] as $el) { - if (!str_starts_with($el, 'https') && str_contains($el, 'upload')) { - $content = str_replace($el, 'https://mkgtu.ru' . $el, $content); - } - } - - return $content; - } - public function cutHTML($content, $strForScissors) - { - - - $arr = []; - // - //safdsaf sdfdasf