urllib2 - 403 that _should_ not occur.

Philip Semanchuk philip at semanchuk.com
Sun Jan 11 21:58:52 EST 2009


On Jan 11, 2009, at 8:59 PM, James Mills wrote:

> Hey all,
>
> The following fails for me:
>
>>>> from urllib2 import urlopen
>>>> f = urlopen("http://groups.google.com/group/chromium-announce/feed/rss_v2_0_msgs.xml 
>>>> ")
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "/usr/lib/python2.6/urllib2.py", line 124, in urlopen
>    return _opener.open(url, data, timeout)
>  File "/usr/lib/python2.6/urllib2.py", line 389, in open
>    response = meth(req, response)
>  File "/usr/lib/python2.6/urllib2.py", line 502, in http_response
>    'http', request, response, code, msg, hdrs)
>  File "/usr/lib/python2.6/urllib2.py", line 427, in error
>    return self._call_chain(*args)
>  File "/usr/lib/python2.6/urllib2.py", line 361, in _call_chain
>    result = func(*args)
>  File "/usr/lib/python2.6/urllib2.py", line 510, in http_error_default
>    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
> urllib2.HTTPError: HTTP Error 403: Forbidden
>>>>
>
> However, that _same_ url works perfectly fine on the
> same machine (and same network) using any of:
> * curl
> * wget
> * elinks
> * firefox
>
> Any helpful ideas ?

The remote server doesn't like your user agent?

It'd be easier to help if you post a working sample.

Cheers
Philip





More information about the Python-list mailing list