Python Basic Auth -


attempting follow this tutorial on basic auth - ends being final example:

import urllib2  theurl = 'http://www.someserver.com/toplevelurl/somepage.htm' username = 'johnny' password = 'xxxxxx' # great password  passman = urllib2.httppasswordmgrwithdefaultrealm() # creates password manager passman.add_password(none, theurl, username, password) # because have put none @ start # use username/password combination  urls # `theurl` super-url  authhandler = urllib2.httpbasicauthhandler(passman) # create authhandler  opener = urllib2.build_opener(authhandler)  urllib2.install_opener(opener) # calls urllib2.urlopen use our handler # make sure not include protocol in url, or # httppasswordmgrwithdefaultrealm confused. # must (of course) use when fetching page though.  pagehandle = urllib2.urlopen(theurl) # authentication handled automatically 

if take , enter own values theurl, username , pw , attempt run script doesn't non of variables seem substituted... doing wrong?


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -