Pythonでベーシック認証

urllib2-exampleのまんま。

import urllib2
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('realm', 'host', 'user', 'passwd')
res = urllib2.build_opener(auth_handler).open('uri')
res.read()