Code - working in one system and not working in the other.
Amal
raj.amal at gmail.com
Wed Dec 26 11:27:31 EST 2007
The following code works in a system with python 2.4.3 and does not work in
the system with python 2.4.2.
And both the systems directly connect to the internet.
import urllib2
url = "http://www.abcd.com"
username = "abcd"
passowrd = "efgh"
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_manager.add_password(None, url, username, passowrd)
authHandler = urllib2.HTTPBasicAuthHandler(password_manager)
opener = urllib2.build_opener(authHandler)
urllib2.install_opener(opener)
pagehandle = urllib2.urlopen(url)
s = pagehandle.read()
print s
url = url+"current/"
pagehandle = urllib2.urlopen(url)
s = pagehandle.read()
print s
url = url+"20071128.zip"
pagehandle = urllib2.urlopen(url)
fp = open("hello.zip", 'wb')
a = pagehandle.readline();
while a != "":
fp.write(a)
a = pagehandle.readline();
#fp.write(pagehandle.read())
fp.close()
in the system it does not run, it gives a urllib2.HTTPError : HTTP Error
401: Authorization required ecception.
With the same user name and password the code runs in another system.
Amal.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071226/15bccdc1/attachment.html>
More information about the Python-list
mailing list