Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34085 > unrolled thread

ntlm authentication for urllib2

Started byJorge Alberto Diaz Orozco <jaorozco@estudiantes.uci.cu>
First post2012-11-29 21:27 -0500
Last post2012-11-29 21:27 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  ntlm authentication for urllib2 Jorge Alberto Diaz Orozco <jaorozco@estudiantes.uci.cu> - 2012-11-29 21:27 -0500

#34085 — ntlm authentication for urllib2

FromJorge Alberto Diaz Orozco <jaorozco@estudiantes.uci.cu>
Date2012-11-29 21:27 -0500
Subjectntlm authentication for urllib2
Message-ID<mailman.376.1354242465.29569.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web