Good day. Actually, what's the problem, the elements I get in half with grief. But there is a certain tendency that during loading I can get the item and I can not get it, who knows what the problem might be? I tried both on hosting and on LAN and on VPS, I sinned that the resource was not enough, it was not the case.

I would be very grateful for the help.

P.S. Here is the link where the script is running, if you update the page a couple times, then you will see the problem. Below is the "code".

<?php require_once 'simple_html_dom.php'; $html = file_get_html('https://koleso2000.ua/shina/zimnyaya/michelin-alpin-a5/195-65r15-91-t-neship'); sleep(5); if(count($html->find("/html",0))) { foreach($html->find('div.in-top p') as $model) {echo ''.$model.'';} echo '<br>'; foreach($html->find('div.second p a',1) as $brand) {$brand = $brand->plaintext; echo ''.$brand.'';} echo '<br>'; foreach($html->find('h1') as $name) {$name = $name->innertext;} echo '<br>'; echo $name; } else { echo "Объект не загружен!"; } $html->clear(); unset($html); ?> 

enter image description here

  • Most likely the problem is that some data is loaded by an Ajax (middle). Try using timeout. - Roman Polshikov
  • sleep (10); - added files after downloading (on the 4th line) , the problem remained ( - Yevgeny Ignatyev
  • Interestingly, it is difficult to select a section of code to copy and paste? Or do you think the person will understand the screenshot and then print the text for the answer? copy the code. - Naumov
  • @RomanPolshikov and still watched, let's say if you immediately display the content received by reference. That often I do not see the whole site, but only pieces, the feeling that I did not have time to load. And after updating the page, the site can be fully loaded, and only the header can. - Yevgeny Ignatyev
  • @Naumov - I frankly tried, but for some reason I didn’t display all the code in the draft - Yevgeny Ignatyev

1 answer 1

Rewrite the HTML request using curl, if necessary, add a timeout in a couple of seconds

 $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,'https://koleso2000.ua/shina/zimnyaya/michelin-alpin-a5/195-65r15-91-t-neship'); 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); echo $result; 
  • Thanks, it works, only in the 3rd line it was still necessary ";" set =) If you don’t frequently access the server, then everything is ok, well, I think this problem can be solved by a timeout, as you wrote =) - Yevgeny Ignatyev