Форум сайта python.su
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('realm', 'reddit.com', 'user_login', 'passwd_login')
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
urllib2.install_opener(opener)
params = urllib.urlencode(dict(user_login='MasulKhan', id_password='qwerty'))
request = urllib2.Request('http://www.reddit.com/', params)
request.add_header('If-Modified-Since', 'Sun, 02 Mar 2008 04:00:08 GMT')
opener.addheaders = [('User-Agent', 'My cool client')]
data = opener.open(request).read()
Офлайн