def login(self, username, password): su = base64.b64encode(urllib.quote(username)) pre_data = self.pre_login(su) sp = self.encrypt_password(password, pre_data) data = { 'client': self.JS_CLIENT, 'entry': 'weibo', 'gateway': '1', 'from': '', 'savestate': '0', 'userticket': '1', 'ssosimplelogin': '******', 'vsnf': '1', 'vsnval': '', 'su': su, 'service': 'miniblog', 'servertime': pre_data.servertime, 'nonce': pre_data.nonce, 'pwencode': 'rsa2', 'prelt': '164', 'sp': sp, 'encoding': 'UTF-8', 'url': 'http://weibo.com/ajaxlogin.php?framelogin=1&callback=parent.sinaSSOController.feedBackUrlCallBack', 'returntype': 'META', 'rsakv': pre_data.rsakv, } response = self._session.post(self.LOGIN_URL, data=data) url = self.URL_REGEX.findall(response.text)[0] query = parse_querystring(url) if query['retcode'] != '0': raise ApiResponseError(response, query['retcode'], query['reason']) return self._session.get(url)
def parse(response): r = response.json_dict() if 'ret' in r and r.ret != 0: raise ApiResponseError(response, r.ret, RET.get(r.ret, u''), r.get('errcode', ''), r.get('msg', '')) if 'data' in r: return r.data return r
def _parse_token(self, response): r = response.json_dict() if 'error_code' in r: raise ApiResponseError( response, r.error_code, r.get('error_description', r.get('error', ''))) return Token(**r)
def _parse_response(self, response): r = response.json_dict() if 'error_response' in r: error = r.error_response raise ApiResponseError(response, error.get('code', ''), error.get('msg', ''), error.get('sub_code', ''), error.get('sub_msg', '')) else: keys = list(r.keys()) if keys and keys[0].endswith('_response'): return r.get(keys[0])
def login(self, username, password): data = dict( username=username, password=password, type=1, product=163, savelogin=1, url='http://www.163.com/special/0077450P/login_frame.html', url2='http://www.163.com/special/0077450P/login_frame.html', noRedirect=1, ) r = self._session.post('https://reg.163.com/logins.jsp', data=data) cookies = dict_from_cookiejar(r.cookies) if 'NTES_PASSPORT' not in cookies: raise ApiResponseError(r, 0, r.text) return r
def login(self, username, password): password = md5(password).hexdigest().lower() data = dict( userid=username, password=password, appid=9999, persistentcookie=1, s=time.time(), b=7, w=1440, pwdtype=1, v=26, ) r = self._session.post('https://passport.sohu.com/sso/login.jsp', data=data) if 'success' not in r.content: raise ApiResponseError(r, 0, r.content.replace('\n', '')) return r
def parse(response): r = response.json_dict() if 'error_code' in r: raise ApiResponseError(response, r.error_code, r.get('error', '')) return r
def _parse_token(self, response): r = response.json_dict() if 'code' in r and 'msg' in r: raise ApiResponseError(response, r.code, r.msg) return Token(**r)
def _parse_token(self, response): data = parse_querystring(response.text) if 'errorCode' in data: raise ApiResponseError(response, data['errorCode'], data.get('errorMsg', '').strip("'")) return Token(**data)
def parse(response): r = response.json_dict() if 'error' in r: raise ApiResponseError(response, r.error, r.get('error_description', '')) return r
def _parse_response(self, response): r = response.json_dict() if 'error' in r and 'code' in r.error: raise ApiResponseError(response, r.error.code, r.error.get('message', '')) return r