MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / task_list

Function task_list

wxapp/quanmianshidai.py:186–233  ·  view source on GitHub ↗
(code, token)

Source from the content-addressed store, hash-verified

184 print(f"请求失败: {e}")
185
186def task_list(code, token): # 任务列表
187 url = "https://sg01.purcotton.com/api/task/list"
188 headers = create_headers(code, token)
189 today_date = datetime.now().strftime("%Y-%m-%d") # 获取今天的日期,格式为YYYY-MM-DD
190
191 # 任务ID到任务名称的映射
192 task_names = {
193 1: "签到, 1",
194 2: "不知道1, 0",
195 4: "三餐福袋, 3",
196 6: "逛甄选好棉品, 4",
197 10: "订阅奖励提醒, 1",
198 13: "浏览新用户, 2",
199 14: "庄园小课堂, 3",
200 15: "棉花工厂, 1",
201 16: "社区送福利, 1"
202 }
203
204 try:
205 response = requests.get(url, headers=headers)
206 response.raise_for_status()
207 response_data = response.json()
208 today_tasks = [] # 用于存储今天的任务信息
209 if response_data.get("code") == 200:
210 task_user_info = response_data.get("data", {}).get("task_user_info", [])
211 print("------任务进度条-----------")
212 for task in task_user_info:
213 task_id = task.get('task_id')
214 complete_num = task.get('complete_num')
215 complete_date = task.get('complete_date')
216 # 比较任务完成日期是否为今天
217 #print("------任务进度条-----------")
218 if complete_date == today_date:
219 task_name = task_names.get(task_id, f"未知任务 {task_id}") # 获取任务名称,如果未知则显示未知任务和ID
220
221 print(f"任务ID: {task_id} {task_name}/{complete_num}, 任务时间: {complete_date}")
222 #print(f"{task_name}/{complete_num} 时间: {complete_date}")
223 today_tasks.append(task)
224 print("-----------------")
225 print()
226 return today_tasks
227
228 else:
229 print(f"获取任务列表失败,错误信息:{response_data.get('msg')}")
230 return []
231 except requests.exceptions.RequestException as e:
232 print(f"请求失败: {e}")
233 return []
234
235
236

Callers 1

pdrwFunction · 0.85

Calls 3

create_headersFunction · 0.85
printFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected