質問
だから、vsearch.cisco.comというサイトからPythonでファイルをダウンロードしようとしています
[python]
#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
[/ python]
私のエラーは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))
テストで試したことは( http://devel.almad.net/trac/django-http-digest/browser/djangohttpdigest/tests/test_simple_digest.py )、あなたのURLにエラーがあります-それを動作させるために、私はホストだけでなくhttp://の部分も含まれています。
所属していません StackOverflow