def authorize(self): c = RequestsCookieJar() ui = util.guid() c.set('ui', ui, path='/', domain='graph.qq.co') self.session.cookies.update(c) cgi_url = 'https://graph.qq.com/oauth2.0/authorize' headers = { 'User-Agent': util.get_user_agents(), 'Referer': 'https://graph.qq.com/oauth2.0/show?which=Login&display=pc&response_type=code&client_id=100497308&redirect_uri=https%3A%2F%2Fy.qq.com%2Fportal%2Fwx_redirect.html%3Flogin_type%3D1%26surl%3Dhttps%253A%252F%252Fy.qq.com%252Fportal%252Fprofile.html%2523stat%253Dy_new.top.user_pic%2526stat%253Dy_new.top.pop.logout%26use_customer_cb%3D0&state=state&display=pc', 'Content-Type': 'application/x-www-form-urlencoded', } payload = { 'response_type': 'code', 'client_id': '100497308', 'redirect_uri': 'https://y.qq.com/portal/wx_redirect.html?login_type=1&surl=https%3A%2F%2Fy.qq.com%2F%23&use_customer_cb=0', 'scope': '', 'state': 'state', 'switch': '', 'from_ptlogin': '******', 'src': '1', 'update_auth': '1', 'openapi': '80901010', 'g_tk': util.get_g_tk(self.session.cookies.get('p_skey')), 'auth_time': str(int(time.time())), 'ui': ui } urlencode = parse.urlencode(payload) post = self.session.post(cgi_url, headers=headers, data=urlencode) return post
def guid(self): if self._guid is self.sentinel: self._guid = guid() return self._guid