Monday 25 November 2019

Simple HTML DOM Error Handling

I have list of website which I am passing to function doScrape() this function creates SimpleHtmlDom object and load the url passed to it as a argument.



But when scrapper is in progress one url can't be loaded and PHP throws following exception




Warning: file_get_contents(http://www.somesite.com) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error in F:\xampp\htdocs\scraping\scrapper\simple_html_dom.php on line 850





Due to this error entire scrapper stops working. How to handle this exception and keep scrapper running event there is an error.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...