Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34085
| Date | 2012-11-29 21:27 -0500 |
|---|---|
| From | Jorge Alberto Diaz Orozco <jaorozco@estudiantes.uci.cu> |
| Subject | ntlm authentication for urllib2 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.376.1354242465.29569.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
ntlm authentication for urllib2 Jorge Alberto Diaz Orozco <jaorozco@estudiantes.uci.cu> - 2012-11-29 21:27 -0500
csiph-web