How to set proxy for a python script to run

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

    How to set proxy for a python script to run

    Hi, everyone, I am using /usr/share/system-config-language/
    language_gui.py in Python.
    For some reason I have to bypass the firewall using a proxy. I read
    the urllib reference and set http_proxy="my proxy". But it didn't
    work. Is there anyway that we can set the proxy?
  • Soltys

    #2
    Re: How to set proxy for a python script to run

    Adam pisze:
    Hi, everyone, I am using /usr/share/system-config-language/
    language_gui.py in Python.
    For some reason I have to bypass the firewall using a proxy. I read
    the urllib reference and set http_proxy="my proxy". But it didn't
    work. Is there anyway that we can set the proxy?

    I did sth. like this:

    proxy_url = "http://user:pass@proxy .yourproxy.org: 8080"
    proxy_support = urllib2.ProxyHa ndler({'http': proxy_url})
    opener = urllib2.build_o pener(proxy_sup port)
    urllib2.install _opener(opener)
    src = urllib2.urlopen (url)

    now you can easily read from src.

    --
    Soltys

    "Free software is a matter of liberty not price"

    Comment

    • subeen

      #3
      Re: How to set proxy for a python script to run

      On Apr 18, 12:31 pm, Adam <Jiang.A...@gma il.comwrote:
      Hi, everyone, I am using /usr/share/system-config-language/
      language_gui.py in Python.
      For some reason I have to bypass the firewall using a proxy. I read
      the urllib reference and set http_proxy="my proxy". But it didn't
      work. Is there anyway that we can set the proxy?
      Check the link: http://love-python.blogspot.com/2008...ur-spider.html

      Comment

      Working...