While parsing the site, throws a 403 error:
raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden
I saw the "solution" with "user agent" but it does not solve (I even have such an error on the site in the browser).
It is necessary exactly the iron solution in the code - in case of 403 errors (preferably the rest) restart the code again.
The problem is that except that neither HTTPError nor urllib.error.HTTPError nor urllib.HTTPError nor urllib.error catches . Unlike ValueError TypeError IndexError with which everything works.
At the beginning of the code imported library with errors from urllib.error import URLError, HTTPError
"
A specific question: how to "catch" this error 403?
except
with a certain error. Did you recheck everything? Maybe you catch a mistake not there, it happens - approximatenumberurllib2
?from urllib2 import URLError, HTTPError
. In the extreme case, if nothing happens, catch the error simply with the help ofexcept Exception as e
. And inside you can handle the error. - approximatenumber