def post_requests(self,response): serverdata = re.findall('{"retcode":0,"servertime":(.*?),"pcid":.*?,"nonce":"(.*?)","pubkey":"(.*?)","rsakv":"(.*?)","is_openlock":.*,"exectime":.*}',response.body,re.I)[0] #获取get请求的数据,用于post请求登录 servertime = serverdata[0] nonce = serverdata[1] pubkey = serverdata[2] rsakv = serverdata[3] username= WeiboSpider.start_username password = WeiboSpider.start_password formdata = { 'entry': 'weibo', 'gateway': '1', 'from': '', 'ssosimplelogin': '******', 'vsnf': '1', 'vsnval': '', 'su': getinfo.get_user(username), 'service': 'miniblog', 'servertime': servertime, 'nonce': nonce, 'pwencode': 'rsa2', 'sp': getinfo.get_pwd(password,servertime,nonce,pubkey), 'encoding': 'UTF-8', 'prelt': '115', 'rsakv': rsakv, 'url':'http://weibo.com/ajaxlogin.php?framelogin=1&callback=parent.sinaSSOController.feedBackUrlCallBack', 'returntype': 'META' } headers={'User-Agent':'Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0 Chrome/20.0.1132.57 Safari/536.11'} return FormRequest(url='http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.4.4)',formdata=formdata,headers=headers,meta={'cookiejar':response.meta['cookiejar']},callback=self.get_cookie)
def post_requests(self,response): serverdata = re.findall('{"retcode":0,"servertime":(.*?),"pcid":.*?,"nonce":"(.*?)","pubkey":"(.*?)","rsakv":"(.*?)","exectime":.*}',response.body,re.I)[0] #获取get请求的数据,用于post请求登录 #print '!!!!GET responsebody:',response.body #print '!!!!serverdata',serverdata[0] servertime = serverdata[0] nonce = serverdata[1] pubkey = serverdata[2] rsakv = serverdata[3] username= WeiboSpider.start_username password = WeiboSpider.start_password formdata = { 'entry': 'weibo', 'gateway': '1', 'from': '', 'ssosimplelogin': '******', 'vsnf': '1', 'vsnval': '', 'su': getinfo.get_user(username), 'service': 'miniblog', 'servertime': servertime, 'nonce': nonce, 'pwencode': 'rsa2', 'sp': getinfo.get_pwd(password,servertime,nonce,pubkey), 'encoding': 'UTF-8', 'prelt': '115', 'rsakv': rsakv, 'url':'http://weibo.com/ajaxlogin.php?framelogin=1&callback=parent.sinaSSOController.feedBackUrlCallBack', 'returntype': 'META' } headers={'User-Agent':'Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0 Chrome/20.0.1132.57 Safari/536.11'} return [FormRequest(url='http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.4.4)',formdata=formdata,headers=headers,callback=self.get_cookie)]
def post_requests(self, response): serverdata = re.findall( '{"retcode":0,"servertime":(.*?),"pcid":.*?,"nonce":"(.*?)","pubkey":"(.*?)","rsakv":"(.*?)","is_openlock":.*,"exectime":.*}', response.body, re.I, )[ 0 ] # 获取get请求的数据,用于post请求登录 servertime = serverdata[0] nonce = serverdata[1] pubkey = serverdata[2] rsakv = serverdata[3] username = WeiboSpider.start_username password = WeiboSpider.start_password formdata = { "entry": "weibo", "gateway": "1", "from": "", "ssosimplelogin": "******", "vsnf": "1", "vsnval": "", "su": getinfo.get_user(username), "service": "miniblog", "servertime": servertime, "nonce": nonce, "pwencode": "rsa2", "sp": getinfo.get_pwd(password, servertime, nonce, pubkey), "encoding": "UTF-8", "prelt": "115", "rsakv": rsakv, "url": "http://weibo.com/ajaxlogin.php?framelogin=1&callback=parent.sinaSSOController.feedBackUrlCallBack", "returntype": "META", } headers = { "User-Agent": "Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0 Chrome/20.0.1132.57 Safari/536.11" } return [ FormRequest( url="http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.4.4)", formdata=formdata, headers=headers, callback=self.get_cookie, ) ]