I'm building a page to crawl some web pages.
It works, usually, but everyone once in a while, it will fail to grab the page, and throw the following error:
( ! ) Warning: file_get_contents(URLWASHERE): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in Z:\Wamp\www\spider\simple_html_dom.php on line 555
Here is how I'm grabbing the page:
$page->load_file('URLWASHERE');
Is there a way to figure out if that error happens? I don't know how to detect it because it's in the library, not my code.
I can't use if (!$page) because it still returns something. But that something doesn't seem very helpful, though it is significantly shorter.
You can see output here:
$page when successful: http://pastebin.com/CnRVP6SK
$page when failed: http://pastebin.com/t9q6Gwnf
I just want to be able to find out if there was an error so I can have my program try again.