Crawler not working

Hi , i want to make crawler to get some data from url , but when i executed this code:

$url = ‘http://transportation-services.findthecompany.com/’;

$dom = new \DOMDocument;

$dom->loadHTMLFile($url);

$rows = $dom->getElementsByTagName(‘tr’);

foreach($rows as $row){

   $tmp[] = $row;

}

Give me this error : "DOMDocument::load(http://transportation-services.findthecompany.com/): failed to open stream: HTTP request failed! HTTP/1.1 416 Requested Range Not Satisfiable"

Thanks

Hi mcirkova,

Hope Doing well,

The problem is the crawling url is not a document object then it will return error so adding @ to the beginning of your loadHTMLFile($url) function will help you.

Please find below for modified code





 $url = 'http://transportation-services.findthecompany.com/';

        $dom = new \DOMDocument;

        $success = @$dom->loadHTMLFile($url);

        $tmp = [];

        if ($success) {

            $rows = $dom->getElementsByTagName('tr');

            foreach ($rows as $row) {

                $tmp[] = $row;

            }

        }



Cheers!

Happy Coding.