所以我正在尝试使用python从名为vsearch.cisco.com的站点下载文件
[蟒蛇]
#Connects to the Cisco Server and Downloads files at the URL specified
import urllib2
#Define Useful Variables
url = 'http://vsearch.cisco.com'
username = 'xxxxxxxx'
password = 'xxxxxxxx'
realm = 'CEC'
# Begin Making connection
# Create a Handler -- Also could be where the error lies
handler = urllib2.HTTPDigestAuthHandler()
handler.add_password(realm,url,username,password)
# Create an Opener
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
try:
urllib2.urlopen(url)
print f.read()
except urllib2.HTTPError, e:
print e.code
print e.header
Run Code Online (Sandbox Code Playgroud)
[/蟒蛇]
我的错误是ValueError:AbstractDigestAuthHandler不知道基本的
我尝试过使用Basic HTML Authorization处理程序甚至HTTPS处理程序.什么都没有让我访问.但是,此错误与所有其他错误不同.其他错误只是401 HTML错误
有关如何做到这一点的任何建议?
"密码管理器"可能有所帮助:
mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
mgr.add_password(None, url, user, password)
urllib2.build_opener(urllib2.HTTPBasicAuthHandler(mgr),
urllib2.HTTPDigestAuthHandler(mgr))
Run Code Online (Sandbox Code Playgroud)