Question

So I'm trying to download a file from a site called vsearch.cisco.com with 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]

My error is ValueError: AbstractDigestAuthHandler doesn't know about basic

I've tried using Basic HTML Authorization handlers and even HTTPS handlers. Nothing gives me access. This error is different from all the other errors however. The other errors are simply 401 HTML errors

Any suggestions on how to do this?

No correct solution

OTHER TIPS

A "password manager" might help:

    mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
    mgr.add_password(None, url, user, password)        
    urllib2.build_opener(urllib2.HTTPBasicAuthHandler(mgr),
                         urllib2.HTTPDigestAuthHandler(mgr))

As for what I tried in my tests (http://devel.almad.net/trac/django-http-digest/browser/djangohttpdigest/tests/test_simple_digest.py), error is prabably in your url - To make it working, I've included http:// part, not only host.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top