Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
handler = urllib2.HTTPBasicAuthHandler()
handler.add_password(realm, domain, webuser, webpass)
11.6 httplib -- HTTP protocol client
This module defines classes which implement the client side of the HTTP and HTTPS protocols. It is normally not used directly -- the module urllib uses it to handle URLs that use HTTP and HTTPS.
import urllib2
handler = urllib2.HTTPBasicAuthHandler()
handler.add_password('AuthName from .htaccess',
'[URL unfurl="true"]www.your.com',[/URL] 'yourusername', 'yourpass')
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
try:
f = urllib2.urlopen( '[URL unfurl="true"]http://www.your.com/path'[/URL] )
except urllib2.HTTPError, e:
if e.code == 401:
print 'not authorized'
elif e.code == 404:
print 'not found'
elif e.code == 503:
print 'service unavailable'
else:
print 'unknown error: '
else:
print 'success'
for line in f:
print line,