发现了一个非常好用的第三方module:requests,模拟接口非常简单。
非常不错
#!coding:utf-8 相信这句大家都懂的,不解释
#导入需要的requests
import requests
#定义请求头
reqheaders={'Content-type':'application/x-www-form-urlencoded', 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Host':'www.renren.com', 'Origin':'http://zhichang.renren.com', 'Referer':'http://zhichang.renren.com', 'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1',}
#定义post的参数,requests模块,参数不用编码
reqdata={'email':[email protected]', 'password':'xxxx', 'autoLogin':'on', 'origURL':'http://zhichang.renren.com/?login_state=rr', 'domain':'renren.com' }