faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 18 people (72%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I use a proxy (I'm behind a firewall) to get HTML pages from the net?

Nov 2nd, 2004 08:08
Jonathan Schroder, unknown unknown, Charlie Derr, Graham Bleach


You have to set an environment variable. 
 
It is http_proxy 
 
# this usually works 
import os, urllib 
os.environ["http_proxy"]="http://firewall.bad.com:9999" 
urllib.urlretrieve('http://www.python.org/') 
# 
 
This should put a copy of said page into a temp file. 
_______________________________________________ 
http://www.python.org/doc/current/lib/module-urllib.html