Unable to connect to internet URL behind firewall

Vytas D. vytasd2013 at gmail.com
Thu Mar 7 04:10:00 EST 2013


Hi,

My guess is that your firewall is blocking the connections. To check this,
disable your firewall and run your python program. If it runs, you have to
configure your firewall to allow your program to connect to the internet.

Vytas


On Wed, Mar 6, 2013 at 4:28 PM, <priyanka.khamankar at gmail.com> wrote:

> Hi,
>
> I am using below two approaches to connect to read the content of internet
> url.
> These two approaches work for me when the internet explorer session is
> open.
>
> When the internet explorer window is closed, below code gives me 407 error.
> I have also set the HTTP_PROXY environment variables as
> http://proxy-example.com:3128
>
> Is there any way that the Python does not use Internet explorer proxy
> settings?
> I want my python script to work even when the IE window is closed.Please
> help.
>
> I am using Python version 2.6. Python code I am using is provide below.
>
> Approach 1:
> import urlib2
>
> # == HTTP ==
> #
> # HTTP with auth info in ProxyHandler is working
> #
> proxy_handler = urllib2.ProxyHandler({'http': '
> http://user:pass@proxy-example.com:3128/'})
> opener = urllib2.build_opener(proxy_handler)
> response = opener.open('http://example.com/testpage.htm')
> print response.read()
>
> Approach 2:
> # HTTP with AuthHandler is working
> #
> proxy_handler = urllib2.ProxyHandler({'http': '
> http://proxy-example.com:3128/'})
> proxy_auth_handler = urllib2.ProxyBasicAuthHandler()
> proxy_auth_handler.add_password('realm', 'proxy-example.com:3128',
> 'user', 'pass')
>
> opener = urllib2.build_opener(proxy_handler, proxy_auth_handler)
> response = opener.open('http://example.com/testpage.htm')
> print response.read()
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130307/2450a633/attachment.html>


More information about the Python-list mailing list