Using proxy
pehr anderson
pehr at pehr.net
Wed Jul 12 02:07:53 EDT 2000
It would appear from looking at /usr/lib/python1.5/urllib.py
that you merely need to set an environment variable.
<scheme>_proxy=XXX
I don't know exactly what these should be but here is the
relevant code snippets from urllib.py in python-1.52.
-pehr
...
class URLopener:
__tempfiles = None
# Constructor
def __init__(self, proxies=None):
if proxies is None:
proxies = getproxies()
...
def getproxies():
"""Return a dictionary of scheme -> proxy server URL mappings.
Scan the environment for variables named <scheme>_proxy;
this seems to be the standard convention. If you need a
different way, you can pass a proxies dictionary to the
[Fancy]URLopener constructor.
"""
proxies = {}
for name, value in os.environ.items():
name = string.lower(name)
if value and name[-6:] == '_proxy':
proxies[name[:-6]] = value
return proxies
Werner Geuens wrote:
>
> I want to retrieve a measurement logfile from a geological measure site at
> regular intervals. The document is available under http form. The function
> urllib.urlretrieve works very well, and cron takes care of the periodic
> launching.
>
> But after on-site testing with a portable, I came back at the office. I
> tested the log file with my browser (all OK), then started the Python
> script and ... nothing.
>
> Turns out it's a proxy problem. I have the needed permissions, do web and
> ftp trough the companies proxy all the time. But how do I go about that
> with python? I'm using Python 1.5.2 on WinNT and OS/2, and will be using
> it under Linux (SUSE 6.2 or 6.4) in a near future.
>
> Any simple solutions?
>
> --
> werner.geuens at skynet.be (Werner Geuens)
> Research is what I'm doing when I don't know what I'm doing.
> Wernher von Braun.
More information about the Python-list
mailing list