I tried to use the following code to get the content on the url
:
request = urllib2.Request(url)
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
response = urllib2.urlopen(request,timeout=20)
I got the error:
urllib2.URLError: <urlopen error [Errno 10054] An existing connection was forcibly closed by the remote host>
But I am able to access the url
using the same credential by a browser.
I solved the issue. Because through the web browser I am actually using a proxy but was not using it in Python script. Later I include the proxy before making the HTTP request and it works.