Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to set proxy for a python script to run

10,061 views
Skip to first unread message

Adam

unread,
Apr 18, 2008, 2:31:30 AM4/18/08
to
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?

Adam

unread,
Apr 18, 2008, 2:52:04 AM4/18/08
to
Hi, I am using a script written in Python. For some reasons I should
pass the fireware by proxy setting. But it seems not work when I set
the 'http_proxy' 'ftp_proxy' environment variable.
I also expored 'HTTP_PROXY' 'FTP_PROXY', but the problem remained.
How can I set proxy for it to run the script?

Soltys

unread,
Apr 18, 2008, 2:55:08 AM4/18/08
to
Adam pisze:


I did sth. like this:

proxy_url = "http://user:pa...@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"

subeen

unread,
Apr 18, 2008, 12:22:15 PM4/18/08
to
0 new messages