def get_token(username, password, deviceId, failtime): while True: user_dict = CampusCard(username, password, deviceId).user_info if user_dict['login'] == False: failtime += 1 logging.warning('登陆失败,五秒后重试... 次数:' + str(failtime)) time.sleep(5) else: return user_dict["sessionId"]
def get_token(username, password): """ 获取用户令牌,模拟登录获取:https://github.com/zhongbr/wanmei_campus :param username: 账号 :param password: 密码 :return: """ user_dict = CampusCard(username, password).user_info if not user_dict['login']: return None return user_dict["sessionId"]
def get_token(username, password): """ 获取用户令牌,模拟登录获取:https://github.com/zhongbr/wanmei_campus :param username: 账号 :param password: 密码 :return: """ for _ in range(5): user_dict = CampusCard(username, password).user_info if not user_dict["login"]: time.sleep(2) continue else: return user_dict["sessionId"] return None
def get_token(username, password): """ 获取用户令牌,模拟登录获取:https://github.com/zhongbr/wanmei_campus :param username: 账号 :param password: 密码 :return: """ for _ in range(10): user_dict = CampusCard(username, password).user_info if user_dict["login"]: return user_dict["sessionId"] elif user_dict['login_msg']['message_'] == "该手机号未注册完美校园": return None elif user_dict['login_msg']['message_'].startswith("密码错误"): return None else: logging.warning('正在尝试重新登录......') time.sleep(5) return None
def get_token(username, password): user_dict = CampusCard(username, password).user_info if not user_dict['login']: return None return user_dict["sessionId"]
def check_in(self): # 模拟登录获取token user_dict = CampusCard(self.lg_username, self.lg_password).user_info token = user_dict["sessionId"] if not user_dict['login']: return None # 获取post提交的字段 post_dict = self.get_post_json(token) if not post_dict: logging.warning('获取完美校园打卡post参数失败') return None # post提交的json字段,根据自己的修改 check_json = { "businessType": "epmpics", "method": "submitUpInfo", "jsonData": { "deptStr": post_dict['deptStr'], "areaStr": post_dict['areaStr'], "reportdate": round(time.time() * 1000), "customerid": post_dict['customerid'], "deptid": post_dict['deptid'], "source": "app", "templateid": post_dict['templateid'], "stuNo": post_dict['stuNo'], "username": post_dict['username'], "phonenum": self.lg_username, "userid": post_dict['userid'], "updatainfo": post_dict['updatainfo'], "gpsType": 1, "token": token }, } response = requests.post(self.check_url, json=check_json) # 以json格式打印json字符串 res = json.dumps(response.json(), sort_keys=True, indent=4, ensure_ascii=False) if response.json()['code'] != '10000': logging.warning(res) else: logging.info(res) # 拼接微信推送输出 now_time = datetime.datetime.now() bj_time = now_time + datetime.timedelta(hours=8) test_day = datetime.datetime.strptime('2020-12-26 00:00:00', '%Y-%m-%d %H:%M:%S') post_msg = "\n".join([ f"| {i['description']} | {i['value']} |" for i in post_dict['checkbox'] ]) date = (test_day - bj_time).days self.server_push(f""" ------ #### 现在时间: ``` {bj_time.strftime("%Y-%m-%d %H:%M:%S %p")} ``` #### json字段: ``` {json.dumps(check_json, sort_keys=True, indent=4, ensure_ascii=False)} ``` #### 打卡信息: ------ | Text | Message | | :----------------------------------- | :--- | {post_msg} ------ ``` {res} ``` ### ⚡考研倒计时: ``` {date}天 ``` > > [GitHub项目地址](https://github.com/ReaJason/17wanxiaoCheckin-Actions) > >期待你给项目的star✨ """)
def get_token(phone, password): stuobj = CampusCard(phone, password).user_info if stuobj['login']: return stuobj["sessionId"] return None
def get_token(self): user_dict = CampusCard(self.lg_username, self.lg_password).user_info if not user_dict['login']: return None self.token = user_dict["sessionId"]