urllib2, proxies and https

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Astan Chee

    urllib2, proxies and https

    Hi again,
    According to

    or more specifically, the example of its working code:

    I can use urllib2 via proxy to access a https site(specifical ly hooking
    it up to libgmail).
    The problem is that the proxy that is accessible to me is http/port8080
    only. Is it possible to use urllib2 with this proxy to access a https
    site? (im guessing no, but im sure there are ways around it).
    I've tried modifying the code to point to a https site
    (https://mail.google.com/mail/) without changing the http proxy and it
    produces a HTTP timeout error.
    Despite this, if I manually use a web browser to access these sites it
    prompts me with the proxy login and lets me through. So im also puzzled
    here why my browser lets this happen but urllib2 doesnt.
    Thanks again for all your help.
    Cheers
    Astan



  • John J. Lee

    #2
    Re: urllib2, proxies and https

    Astan Chee <stanc@al.com.a uwrites:
    Hi again,
    According to

    or more specifically, the example of its working code:

    I can use urllib2 via proxy to access a https site(specifical ly
    hooking it up to libgmail).
    [...]

    The code at that URL seems to be claiming you CAN'T do that, even with
    HTTP URLs (note HTTP, not HTTPS). Hopefully (s)he is complaining
    about 2.4 -- there are a bunch of bugs with this kind of thing fixed
    in Python 2.5.

    Re HTTPS: urllib2 does not support the CONNECT method (nor urllib, I
    think), so no, you can't visit HTTPS URLS through a proxy with vanilla
    urllib2. There are some hacks lying around in the cookbook and on the
    Python SF tracker showing how to do it, though.


    John

    Comment

    Working...