Skip to content Skip to sidebar Skip to footer

Python Webdriver Raises Http.client.badstatusline Error

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

Solution 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

Post a Comment for "Python Webdriver Raises Http.client.badstatusline Error"