Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!rt.uk.eu.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.134 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.74; '*S*': 0.00; 'error:': 0.05; 'urllib2': 0.07; 'inserted': 0.09; 'password)': 0.09; 'subject:skip:a 10': 0.09; 'ntlm': 0.16; 'proxy,': 0.16; 'skip:u 30': 0.17; 'import': 0.21; 'parse': 0.22; "i've": 0.23; 'script': 0.24; 'tried': 0.25; 'header:User-Agent:1': 0.26; 'wrote': 0.26; "doesn't": 0.28; 'all.': 0.28; 'received:10.0.0': 0.28; "i'm": 0.29; 'url:non- standard http port': 0.30; 'print': 0.32; 'received:10.0': 0.33; 'to:addr:python-list': 0.33; 'open': 0.35; 'something': 0.35; 'skip:u 20': 0.36; 'but': 0.36; 'data.': 0.36; 'header:Received:9': 0.36; 'skip:p 20': 0.36; 'behind': 0.38; 'some': 0.38; 'things': 0.38; 'received:10': 0.38; 'sure': 0.38; 'page': 0.38; 'to:addr:python.org': 0.39; 'help': 0.40; 'skip:u 10': 0.60; 'url:ip addr': 0.62; 'received:unknown': 0.63; 'grab': 0.64; 'url:10': 0.65; 'url:0': 0.67; 'url:facebook': 0.67; 'received:200': 0.71; 'url:i': 0.78; 'futuro,': 0.84; 'opener': 0.84; 'universidad': 0.84; 'url:photos': 0.84; 'url:cu': 0.91; 'url:url': 0.96 X-Virus-Scanned: amavisd-new at uci.cu Date: Thu, 29 Nov 2012 21:27:19 -0500 From: Jorge Alberto Diaz Orozco User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: python-list@python.org Subject: ntlm authentication for urllib2 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354242465 news.xs4all.nl 6856 [2001:888:2000:d::a6]:53660 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34085 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