Re: urllib2 - 403 that _should_ not occur.

Discussion in 'Python' started by Chris Mellon, Jan 12, 2009.

  1. Chris Mellon

    Chris Mellon Guest

    On Sun, Jan 11, 2009 at 9:05 PM, James Mills
    <> wrote:
    > On Mon, Jan 12, 2009 at 12:58 PM, Philip Semanchuk <> wrote:
    >>
    >> 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.

    >
    > That was a working sample! The "User-Agent" didn't
    > occur to me :) Thanks - I think that might be it.
    >
    > Why Google would deny access to services by
    > unknown User Agents is beyond me - especially
    > since in most cases User Agents strings are not
    > strict.


    If you look at the actual response text and not just the error code,
    you will get a clear explanation of why you were forbidden.
     
    Chris Mellon, Jan 12, 2009
    #1
    1. Advertising

  2. On Mon, 12 Jan 2009 00:38:20 -0600, Chris Mellon wrote:

    >> Why Google would deny access to services by unknown User Agents is
    >> beyond me - especially since in most cases User Agents strings are not
    >> strict.

    >
    > If you look at the actual response text and not just the error code, you
    > will get a clear explanation of why you were forbidden.


    You have a funny idea of what constitutes a "clear explanation".


    <H1>Forbidden</H1>
    Your client does not have permission to get URL <code>/group/chromium-
    announce/feed/rss_v2_0_msgs.xml</code> from this server.


    That hardly explains "Why Google would deny access to services by unknown
    User Agents", does it?



    --
    Steven
     
    Steven D'Aprano, Jan 12, 2009
    #2
    1. Advertising

  3. Chris Mellon

    Chris Mellon Guest

    On Mon, Jan 12, 2009 at 4:34 PM, Steven D'Aprano
    <> wrote:
    > On Mon, 12 Jan 2009 00:38:20 -0600, Chris Mellon wrote:
    >
    >>> Why Google would deny access to services by unknown User Agents is
    >>> beyond me - especially since in most cases User Agents strings are not
    >>> strict.

    >>
    >> If you look at the actual response text and not just the error code, you
    >> will get a clear explanation of why you were forbidden.

    >
    > You have a funny idea of what constitutes a "clear explanation".
    >
    >
    > <H1>Forbidden</H1>
    > Your client does not have permission to get URL <code>/group/chromium-
    > announce/feed/rss_v2_0_msgs.xml</code> from this server.
    >
    >
    > That hardly explains "Why Google would deny access to services by unknown
    > User Agents", does it?
    >
    >


    I suppose I should have checked that specific URL. The search results
    pages (last I checked) gave a detailed error message.
     
    Chris Mellon, Jan 12, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Storr
    Replies:
    0
    Views:
    492
    Simon Storr
    Jul 14, 2003
  2. Miguel Dias Moura
    Replies:
    4
    Views:
    466
    Hans Kesting
    May 6, 2004
  3. Josef Cihal
    Replies:
    0
    Views:
    797
    Josef Cihal
    Sep 5, 2005
  4. James Mills

    urllib2 - 403 that _should_ not occur.

    James Mills, Jan 12, 2009, in forum: Python
    Replies:
    11
    Views:
    1,200
    Steve Holden
    Jan 14, 2009
  5. willem joubert

    Error 403-Error 403-Error 403

    willem joubert, Feb 8, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    191
    Bruce Johnson [C# MVP]
    Feb 8, 2005
Loading...

Share This Page