urlopen through firewall

Fredrik Lundh effbot at telia.com
Fri Feb 4 16:48:40 EST 2000


<F note="mailed and posted">

Xose L. Gonzalez wrote:
> When I try to connect to the webserver through  "urlopen", it is
> impossible when inside firewall, whereas the same code works without
> firewall involved
>
> which is the solution?

set the http_proxy environment variable to point to your
proxy server.  e.g:

    import os, urllib

    os.environ["http_proxy"] = http://proxy.spam.egg:1234"

    # connect to www.python.org through proxy.spam.egg:1234
    fp = urllib.urlopen("http://www.python.org")

if you prefer, you can of course set the environment
variable outside your program (using the usual shell
commands).

</F>





More information about the Python-list mailing list