使用Python-NTLM时出现IndexError

2024-03-29 00:38:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用urllib2python-ntlm连接到一个经过NT认证的服务器,但是遇到了一个错误。我使用的代码来自the python-ntlm site

user = 'DOMAIN\user.name'
password = 'Password123'
url = 'http://corporate.domain.com/page.aspx?id=foobar'

passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, user, password)
# create the NTLM authentication handler
auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)

# create and install the opener
opener = urllib2.build_opener(auth_NTLM)
urllib2.install_opener(opener)

# retrieve the result
response = urllib2.urlopen(url)
return response.read()

我得到的错误是:

^{pr2}$

你知道我做错什么了吗?在


Tags: installtheauthurlresponse错误createpassword