Reputation: 12714
I am trying to open an url through python like this
import urllib2
f = urllib2.urlopen('http://www.futurebazaar.com/Search/laptop')
It's throwing following error
File "C:\Python26\lib\urllib2.py", line 1134, in do_open r = h.getresponse() File "C:\Python26\lib\httplib.py", line 986, in getresponse response.begin() File "C:\Python26\lib\httplib.py", line 391, in begin version, status, reason = self._read_status() File "C:\Python26\lib\httplib.py", line 355, in _read_status raise BadStatusLine(line) httplib.BadStatusLine
But this url is opening via browser.
Upvotes: 0
Views: 1818
Reputation: 57464
The website is broken. If the optional "Accept" header isn't supplied, the site closes the connection without responding; this is invalid behavior.
Workaround:
import urllib2
req = urllib2.Request('http://www.futurebazaar.com/Search/laptop')
req.add_header('Accept', '*/*')
f = urllib2.urlopen(req)
Upvotes: 5