问题
I'm writing a parser and I'm using Selenium Webdriver. So, I have this https://repl.it/Dgtp code and it's working fine until one random element and throws following exception:
http.client.BadStatusLine: ''
Don't know how to fix it at all. Help.
[UPD]
I tried to scroll the page via webdriver (it had to cause thumbnails to load) and got this https://repl.it/DkiX error series. It would be caused by HTTP error from one of images which were loading, but I've not found any loading errors on the page. Still searching the answer.
回答1:
This is a urllib
problem. This happens most commonly in python3. What it means is that the status code that the server returned isn't recognized by the http library. Sometimes the server doesn't receive the request at all and the status code returns an empty string triggering that error.
How to fix
Check if the URL string has a trailing newline character. Make sure that your URLs are stripped of any leading or trailing special characters. More info here
If everything looks fine with the URL just treat the exception
import http
try:
browser.get(MONTHLY_URL)
except http.client.HTTPException as e:
print e
来源:https://stackoverflow.com/questions/39681605/python-webdriver-raises-http-client-badstatusline-error