How to set proxy for a python script to run
Soltys
soltys at noabuse.com
Fri Apr 18 02:55:08 EDT 2008
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.ProxyHandler({'http': proxy_url})
opener = urllib2.build_opener(proxy_support)
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"
More information about the Python-list
mailing list