I am running the following command and getting an exception:
$headers = get_headers(“http://www.moneysupermarket.com/mortgages/“, 1);
How do I handle this exception (in my case, ignore this url as it is causing an exception).
I have tried:
- try/catch
- The code in this link: https://stackoverflow.com/a/6184127/1486303
However, I still get this error appear (which I want ignored).
Thanks!
NEW VERSION
Again this’s not the right answer of the question, but avoiding the error, can give the expected result.
get_headers do an HTTP GET without Agent, so moneysupermarket.com don’t like it, so use ini_set to set the default user agent in request, and all work well:
PREVIOUS
Apparently moneysupermarket.com reset a connection if request is not well formatted, do the request using cUrl (take from curl man page):