This commit is contained in:
aslan 2024-01-31 15:45:07 +03:00
parent 7a585aa3cd
commit 18c4e21d06
1 changed files with 36 additions and 35 deletions

View File

@ -93,41 +93,42 @@ class PageScrapper
$links = $content->find('a[href]'); $links = $content->find('a[href]');
$srclinks = $content->find('img[src]'); $srclinks = $content->find('img[src]');
// $html0 = $this->document->format()->html();
$html0 = $content->html(); // dd($html0);
foreach ($links as $k => $link) { // $html0 = $content->find('a[href]')->set;
$href = $link->attr('href'); // foreach ($links as $k => $link) {
// $href = $link->attr('href');
if (!str_contains($link->attr('href'), "https://")) { //
// if (!str_contains($link->attr('href'), "https://")) {
//
$tmp = explode('/', rawurldecode($href)); //
foreach ( $tmp as $k => $v) { // $tmp = explode('/', rawurldecode($href));
$tmp[$k] = rawurlencode($v); // foreach ( $tmp as $k => $v) {
} // $tmp[$k] = rawurlencode($v);
$href = implode('/', $tmp); // }
// $href = implode('/', $tmp);
// $newHref = 'https://mkgtu.ru' . $href;
$html0 = str_replace($href, 'https://mkgtu.ru' . $href, $html0); // echo 'https://mkgtu.ru' . $href;
} // echo '<br>';
} // echo '<br>';
foreach ($srclinks as $k => $srclink) { // $html0 = str_replace($href, $newHref, $html0);
$src = $srclink->attr('src'); // }
// }
if (!str_contains($srclink->attr('src'), "https://")) { // foreach ($srclinks as $k => $srclink) {
// $src = $srclink->attr('src');
//
$tmp = explode('/', rawurldecode($src)); // if (!str_contains($srclink->attr('src'), "https://")) {
foreach ( $tmp as $k => $v) { // $tmp = explode('/', rawurldecode($src));
$tmp[$k] = rawurlencode($v); // foreach ($tmp as $k => $v) {
} // $tmp[$k] = rawurlencode($v);
$src = implode('/', $tmp); // }
// $src = implode('/', $tmp);
//
$html0 = str_replace($src, 'https://mkgtu.ru' . $src, $html0); //
} // $html0 = str_replace($src, 'https://mkgtu.ru' . $src, $html0);
} // }
str_replace('st yle', 'style', $html0); // }
// str_replace('st yle', 'style', $html0);
return $html0; return $html0;
} }