Good day to all, I actually wrote a small parser quickly using Simple HTML DOM , everything actually works as I need except for one thing, I get links to products from the category page, write them into an array and then try to parse each page, but not here It was, for me (the parser), for some reason, it drops to 404 pages, if you write the link manually and not take it from the array, then everything works properly. Can anyone come across, what can you advise? The code is attached below.
<?php $url=$_GET['url']; $site_url = 'https://koleso2000.ua'; $category_url = 'https://koleso2000.ua/shini'; if(isset($url) && $url != "") { require_once 'simple_html_dom.php'; for($i=1;$i<=1;$i++) { $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $category_url.'?page='.$i.''); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result_category = curl_exec($ch); curl_close($ch); $html_category = str_get_html($result_category); if(count($html_category->find("/html",0))) { foreach($html_category->find('div.productsWrap a') as $href) { if($href->plaintext != 'Купить ') { if($href->href != $duble) { $product_url[] = $site_url.$href->href.'</br>'; $duble = $href->href; } } } } else { echo 'Не загружен объект категории!'; } } foreach($product_url as $url_product) { $ch = curl_init(); curl_setopt($ch,CURLOPT_URL, $url_product ); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); $html = str_get_html($result); if(count($html->find("/html",0))) { $price = $html->find('span.price',0); $price = $price->plaintext; $price = str_replace(" грн ", "", $price); $price = strip_tags($price); $image = $html->find('img',2); $image_src = $image->src; $image_alt = $image->alt; $image = '<a href="https://koleso2000.ua/'.$image_src.'">'.$image_alt.'</a></br>'; $name = $html->find('h1',0);; $name = $name->innertext; $name = strip_tags($name); $brand = $html->find('div.second p a',1); $brand = $brand->plaintext; $brand = strip_tags($brand); $model = $html->find('div.in-top p',0); $model = strip_tags($model); $model = str_replace(" ", "", $model); $model = explode(':',$model); $model = $model[1]; $width = $html->find('div.second p',2); $width = $width->plaintext; $width = strip_tags($width); $height = $html->find('div.second p',3); $height = $height->plaintext; $height = strip_tags($height); $diameter = $html->find('div.second p',4); $diameter = $diameter->plaintext; $diameter = strip_tags($diameter); $speed = $html->find('div.second p',5); $speed = $speed->plaintext; $speed = strip_tags($speed); $weight = $html->find('div.second p',6); $weight = $weight->plaintext; $weight = strip_tags($weight); $season = $html->find('div.second p',7); $season = $season->plaintext; $season = strip_tags($season); $ship = $html->find('div.second p',8); $ship = $ship->plaintext; $ship = strip_tags($ship); $type = $html->find('div.second p',9); $type = $type->plaintext; $type = strip_tags($type); echo '<img src="https://koleso2000.ua/'.$image_src.'" alt="'.$image_alt.'" style = "width:200px;"><br><br>'; echo 'Наименование - '.$name.'<br>'; echo 'Цена - '.$price.'<br>'; echo 'Картинка - '.$image.''; echo 'Бренд - '.$brand.'<br>'; echo 'Код - '.$model.'<br>'; echo 'Ширина - '.$width.'<br>'; echo 'Высота - '.$height.'<br>'; echo 'Диаметр - '.$diameter.'<br>'; echo 'Индекс скорости - '.$speed.'<br>'; echo 'Индекс нагрузки - '.$weight.'<br>'; echo 'Сезон - '.$season.'<br>'; echo 'Шипы - '.$ship.'<br>'; echo 'Тип - '.$type.'<br><br>'; } else { echo "Объект не загружен!"; } $html->clear(); unset($html); } } else { echo 'Не передана ссылка на страницу'; } ?>