#encoding=utf-8 import requests import hashlib urls = 'http://127.0.0.1/login.htm' pwdstr = 'b352d8c1ca9cfde7a5d16c2371e10ceb' #str2 = pwdstr.encode('utf8') def md5(str): m = hashlib.md5() m.update(str) return m.hexdigest() str1=md5('username') str2=md5('password') print str1 +'\r\n' print str2 +'\r\n' postdata = { 'pwd':pwdstr, 'username':'userpassword', 'password':'password', } #headers = { 'User-Agent' : '123'} session = requests.session() response = session.post(urls,postdata) #s = requests.session(urls,postdata) #print response.cookies #print response.text #print '----------' print response.content
參考網絡部份內容如模擬登陸淘寶,模擬登陸www.zhihu.com等內容。cookie