<div dir="ltr"><div>Hi,<br><br></div><div>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.</div>
<div><br></div>Vytas<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 6, 2013 at 4:28 PM,  <span dir="ltr"><<a href="mailto:priyanka.khamankar@gmail.com" target="_blank">priyanka.khamankar@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I am using below two approaches to connect to read the content of internet url.<br>
These two approaches work for me when the internet explorer session is open.<br>
<br>
When the internet explorer window is closed, below code gives me 407 error.<br>
I have also set the HTTP_PROXY environment variables as <a href="http://proxy-example.com:3128" target="_blank">http://proxy-example.com:3128</a><br>
<br>
Is there any way that the Python does not use Internet explorer proxy settings?<br>
I want my python script to work even when the IE window is closed.Please help.<br>
<br>
I am using Python version 2.6. Python code I am using is provide below.<br>
<br>
Approach 1:<br>
import urlib2<br>
<br>
# == HTTP ==<br>
#<br>
# HTTP with auth info in ProxyHandler is working<br>
#<br>
proxy_handler = urllib2.ProxyHandler({'http': '<a href="http://user:pass@proxy-example.com:3128/'" target="_blank">http://user:pass@proxy-example.com:3128/'</a>})<br>
opener = urllib2.build_opener(proxy_handler)<br>
response = opener.open('<a href="http://example.com/testpage.htm" target="_blank">http://example.com/testpage.htm</a>')<br>
print response.read()<br>
<br>
Approach 2:<br>
# HTTP with AuthHandler is working<br>
#<br>
proxy_handler = urllib2.ProxyHandler({'http': '<a href="http://proxy-example.com:3128/'" target="_blank">http://proxy-example.com:3128/'</a>})<br>
proxy_auth_handler = urllib2.ProxyBasicAuthHandler()<br>
proxy_auth_handler.add_password('realm', '<a href="http://proxy-example.com:3128" target="_blank">proxy-example.com:3128</a>', 'user', 'pass')<br>
<br>
opener = urllib2.build_opener(proxy_handler, proxy_auth_handler)<br>
response = opener.open('<a href="http://example.com/testpage.htm" target="_blank">http://example.com/testpage.htm</a>')<br>
print response.read()<br>
<span class="HOEnZb"><font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div>