400 Bad Request calling urllib2.urlopen()

Achim Domma domma at procoders.net
Mon Sep 3 09:06:57 EDT 2007


Hi,

I have an url which redirects the client to another url. If I paste
the url into a browser, it works fine. If I open it via
urllib2.urlopen() I get the following error:

Traceback (most recent call last):
  File "...\crawlRawDocuments.py", line 16, in <module>
    body = urlopen(url).read()
  File "C:\Python25\lib\urllib2.py", line 121, in urlopen
    return _opener.open(url, data)
  File "C:\Python25\lib\urllib2.py", line 380, in open
    response = meth(req, response)
  File "C:\Python25\lib\urllib2.py", line 491, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python25\lib\urllib2.py", line 412, in error
    result = self._call_chain(*args)
  File "C:\Python25\lib\urllib2.py", line 353, in _call_chain
    result = func(*args)
  File "C:\Python25\lib\urllib2.py", line 575, in http_error_302
    return self.parent.open(new)
  File "C:\Python25\lib\urllib2.py", line 380, in open
    response = meth(req, response)
  File "C:\Python25\lib\urllib2.py", line 491, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python25\lib\urllib2.py", line 418, in error
    return self._call_chain(*args)
  File "C:\Python25\lib\urllib2.py", line 353, in _call_chain
    result = func(*args)
  File "C:\Python25\lib\urllib2.py", line 499, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request

I'm using Python 2.5.1 and Google did not help. Any hint on how to fix
or debug this problem?

regards,
Achim




More information about the Python-list mailing list