Hi there:
I'm working with urllib2 to open some urls and grab some data. The url will be inserted by the user and my script will open it and parse the page for results. the thing is I'm behind a ntlm proxy, and I've tried with a lot of things to authenticate but it still doesn't work at all.
I did some research and found pytho-ntlm but I'm not sure how to use it.


I wrote something like this and it still giving me an authentication error:
Can someone help me???

import urllib2
from HTTPNtlmAuthHandler import HTTPNtlmAuthHandler
url = 'http://url.i.want.to.parse'
user = u'DOMAIN\\myuser'
password = 'mypass'

passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, user , password)
auth_NTLM = HTTPNtlmAuthHandler(passman)
proxy_handler = urllib2.ProxyHandler({'http': 'http://10.0.0.1:8080'})

opener = urllib2.build_opener(proxy_handler, auth_NTLM)
urllib2.install_opener(opener)

response = urllib2.urlopen(url)

print 'done'
print(response.read())

10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS 
INFORMATICAS...
CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION

http://www.uci.cu
http://www.facebook.com/universidad.uci
http://www.flickr.com/photos/universidad_uci
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to