易采站長站,站長之家為您整理了Python實現(xiàn)超星學(xué)習(xí)通簽到(學(xué)習(xí)記錄貼)——(4月1日更新的相關(guān)內(nèi)容。
if var2[0] == "activePrimaryId": return var2[1] return "error" def Sign(self, courseId, classId): global activities, course_data url = "https://mobilelearn.chaoxing.com/ppt/activeAPI/taskactivelist?courseId=" + str( courseId) + "&classId=" + str(classId) + "&uid=" + uid response = requests.get(url, headers=self.headers, cookies=cookie) if response.status_code == 200: data = json.loads(response.text) activeList = data['activeList'] for i in activeList: if "nameTwo" not in i: continue if i['activeType'] == 2 and i['status'] == 1: sign_url = i['url'] # 提取activePrimaryId aid = self.aid_get(sign_url) if aid not in activities: print(course_data[i]['name'], '查詢到可簽到活動 活動名稱:%s 活動狀態(tài):%s 活動時間:%s aid:%s' % (i['nameOne'], i['nameTwo'], i['nameFour'], aid)) self.sign_task(aid, uid) return True else: return False def sign_task(self, aid, uid): global activities url = "https://mobilelearn.chaoxing.com/pptSign/stuSignajax" objectId = self.uploadPicture() res = requests.post(url, data={"name": name, "address": address, 'activeId': aid, 'uid': uid, 'longitude': longitude, 'latitude': latitude, 'objectId': objectId}, headers=self.headers, cookies=cookie) if res.text == "success": print(" 簽到成功!") self.smtp("簽到成功") activities.append(aid) else: print(res.text, '簽到失敗') self.smtp("簽到失敗") activities.append(aid) # 上傳圖片需要token def getTokenValue(self): url = 'https://pan-yz.chaoxing.com/api/token/uservalid' res = requests.get(url, headers=self.headers, cookies=cookie) t_dict = json.loads(res.text) return t_dict['_token'] def uploadPicture(self): # global picture_name, uid if picture_name.isspace() or len(picture_name) == 0: print("圖片參數(shù)錯誤,請檢查") return else: url = 'https://pan-yz.chaoxing.com/upload' files = {'file': (picture_name, open(picture_name, 'rb'), 'image/webp,image/*',), } data = { 'puid': uid, '_token': self.getTokenValue() } response = requests.post(url, data=data, files=files, headers=self.headers, cookies=cookie)以上就是關(guān)于對Python實現(xiàn)超星學(xué)習(xí)通簽到(學(xué)習(xí)記錄貼)——(4月1日更新的詳細(xì)介紹。歡迎大家對Python實現(xiàn)超星學(xué)習(xí)通簽到(學(xué)習(xí)記錄貼)——(4月1日更新內(nèi)容提出寶貴意見
|