记一点东西
cj = cookielib.CookieJar() url_login = 'http://example?action=login' params = (('username','ruyiqiane'), ('password', '******')) opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [('User-agent', 'Opera/9.23')] urllib2.install_opener(opener) req=urllib2.Request(url_login,urllib.urlencode(params)) response=urllib2.urlopen(req)