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]');
$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);
// $html0 = $this->document->format()->html();
// dd($html0);
// $html0 = $content->find('a[href]')->set;
// 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);
// $newHref = 'https://mkgtu.ru' . $href;
// echo 'https://mkgtu.ru' . $href;
// echo '<br>';
// echo '<br>';
// $html0 = str_replace($href, $newHref, $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;
}