def _ptlogin(self): url = 'http://ptlogin2.qq.com/login' params = { 'u': self.uid, 'p': self.encodepwd, 'verifycode': self.verify, 'u1': 'http://web2.qq.com/loginproxy.html?strong=true', 'remember_uin': 1, 'aid': 1003903, 'h': 1, 'ptredirect': 0, 'ptlang': 2052, 'from_ui': 1, 'pttype': 1, 'dumy': '', 'fp': 'loginerroralert', } self.cookies['verifysession'] = self.verify Headers['Cookie'] = self.cookies.output() resp, content = Get(url, params=params, headers=Headers) self.cookies = Cookie(resp.get('set-cookie', '')) match = CB.match(content) if int(match.group('one')) == 0: return True else: return False
def _prelogin(self): url = 'http://ptlogin2.qq.com/login' params = { 'u':self.id, 'p':self.encodepwd, 'verifycode':self.verify, 'u1':'http://web2.qq.com/loginproxy.html?strong=true', 'remember_uin':1, 'aid':1003903, 'h':1, 'ptredirect':0, 'ptlang':2052, 'from_ui':1, 'pttype':1, 'dumy':'', 'fp':'loginerroralert', } self.cookies['verifysession'] = self.verify Headers['Cookie']=self.cookies.output() resp,content = Get(url,params=params,headers=Headers) self.cookies = Cookie(resp.get('set-cookie','')) match = CB.match(content) if int(match.group('one')) == 0: return True else: return False
def _check(self): url = 'http://ptlogin2.qq.com/check' params = { 'uin':self.id, 'appid':1003903 } resp, content = Get(url,params = params,headers=Headers) logging.info('check:%s',content) self.cookies = Cookie(resp.get('set-cookie','')) match = CheckVC.match(content) self.verify = match.group('content') return int(match.group('status')),self.verify
def _channel_poll2(self): url = 'http://d.web2.qq.com/channel/poll2' params ={ 'clientid':self.clientid, 'psessionid':self.psessionid, 't':int(time.time()), 'vfwebqq':self.vfwebqq } Headers['Cookie'] = getcookiestr(self.cookies) resp,content = Get(url,params=params,headers=Headers) self.cookies=Cookie(resp.get('set-cookie','')) print resp print content
def _channel_poll(self): url = 'http://web2-b.qq.com/channel/poll' params = { 'clientid':self.clientid, 'psessionid':self.psessionid, 't':int(time.time()) } Headers['Cookie']=getcookiestr(self.cookies) resp,content = Get(url,params=params,headers=Headers) self.cookies = Cookie(resp.get('set-cookie','')) content_dict= json.loads(content) if resp['status'] == '200' and content_dict['retcode'] == 0: return content_dict['result'] else: logging.error('resp:%s,content:%s',str(resp),content) return None