P
priyanka.khamankar
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:[email protected]: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()
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:[email protected]: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()