def auth_visitor_login(): login_session = requests.session() timestamp = int(time.time() * 1000) data = { "platform": 3, "deviceToken": "B5E1B1E4-BAA1-4F06-9011-A1E21A99DA79", "deviceName": "iPhone 6s", "sign": helper.get_str_md5(helper.APP_AES_KEY + "B5E1B1E4-BAA1-4F06-9011-A1E21A99DA79" + str(timestamp) + helper.APP_AES_KEY), "timestamp": timestamp } json_data = json.dumps(data) response = login_session.post(urls.auth_visitor_login, data=json_data, headers={"Content-Type": "application/json"}) if response.status_code != 200: print("uc登录异常: {}".format(response.text)) ret_json = helper.check_json_response(response) login_session.close() if int(ret_json['code']) != 200: print("uc登录异常:{}".format(ret_json)) return ret_json
def __init__(self, username, password='******', login=True): self.username = username self.password = password self.request_session = requests.session() self.user_token = "" self.user_id = 0 self.__is_login = login if self.__is_login: rs, user_token = usercenter_api.pc_login(self.username, self.password) self.request_session = rs self.user_token = user_token self.user_id = int(user_token.split('-')[0])
def auth_pc_login(username, password='******'): login_session = requests.session() encrypt_password = helper.encrypt_pc_password(password) data = {"userName": username, "password": encrypt_password, "platform": 1} json_data = json.dumps(data) response = login_session.post(urls.auth_pc_login, data=json_data, headers={"Content-Type": "application/json"}) if response.status_code != 200: print("uc登录异常: {}".format(response.text)) ret_json = helper.check_json_response(response) login_session.close() if int(ret_json['code']) != 200: print("uc登录异常:{}".format(ret_json)) return ret_json
def __init__(self, username, password='******', login=True, sid=2, version='7.8.1'): self.username = username self.password = password self.sid = sid self.request_session = requests.session() self.user_token = "" self.user_id = 0 self.__is_login = login self.version = version if self.__is_login: user_token = usercenter_api.app_login(self.username, self.password) self.user_token = user_token self.user_id = int(user_token.split('-')[0]) userid_keybin = 30205014 self.__userid = int(userid_keybin ^ self.user_id)
def __init__(self, username=None, password='******', openid=None): self.username = username self.password = password self.request_session = requests.session() self.user_token = "" self.user_id = 0 if username: user_token = usercenter_api.auth_app_login(self.username, self.password) self.user_token = user_token[-1] elif openid: self.user_token = usercenter_api.auth_third_login()['data']['token'] else: self.user_token = usercenter_api.auth_visitor_login()['data']['token'] self.user_id = int(self.user_token.split('-')[0])
def app_login(username, password='******'): login_session = requests.session() encrypt_password = helper.encrypt_app_password(password) data = "password={0}&sign=10d20dd481a694bf73bbd75aa41062e9" \ "&devicename=iPhone 6s&devicetoken=B5E1B1E4-BAA1-4F06-9011-A1E21A99DA79" \ "&platform=2×tamp={2}&username={1}&" \ "token=&sid=7".format(encrypt_password, username, int(time.time() * 1000)) response = login_session.post( urls.app_login, data=data, headers={"Content-Type": "application/x-www-form-urlencoded"}, verify=False) if response.status_code != 200: print("uc登录异常: {}".format(response.text)) ret_json = helper.check_json_response(response) login_session.close() if int(ret_json['code']) != 200: print("uc登录异常: {}".format(ret_json)) return ret_json['data']['member']['token']
def pc_login(username, password='******', platform=1): aes_password = helper.encrypt_pc_password(password) queries = { "userName": username, "password": aes_password, "platform": platform } login_session = requests.session() response = login_session.post(urls.auth_login, json=queries) if response.status_code != 200: print("uc登录异常: {}".format(response.text)) res_json = json.loads(response.text) if int(res_json['code']) != 200: print("uc登录异常: {}".format(res_json)) user_token = res_json['data']['token'] login_session.cookies.set(name='ewt_user', value='tk={0}&info={1}'.format( res_json['data']['token'], res_json['data']['info']).replace('\n', '')) return login_session, user_token
def auth_app_login(username='******', password='******'): login_session = requests.session() encrypt_password = helper.encrypt_app_password(password) # platform: 1:WEB,2:ANDROID,3:IOS data = { "userName": username, "password": encrypt_password, "platform": 3, "deviceToken": "B5E1B1E4-BAA1-4F06-9011-A1E21A99DA79", "deviceName": "iPhone 6s" } json_data = json.dumps(data) response = login_session.post(urls.auth_app_login, data=json_data, headers={"Content-Type": "application/json"}) if response.status_code != 200: print("uc登录异常: {}".format(response.text)) ret_json1 = helper.check_json_response(response) login_session.close() if int(ret_json1['code']) != 200: print("uc登录异常: {}".format(ret_json1)) return ret_json1, ret_json1['data']['token']
def __init__(self, schoolid): self.schoolid = schoolid self.request_session = requests.session() self.token4oa = '' self.oatoken = self.__get_oatoken(schoolid=self.schoolid)