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

Function hdwt_box

wxapp/quanmianshidai.py:459–513  ·  view source on GitHub ↗
(code, token, tid)

Source from the content-addressed store, hash-verified

457
458# 回答问题
459def hdwt_box(code, token, tid): #庄园小课堂
460 url = "https://sg01.purcotton.com/api/answer"
461 headers = create_headers(code, token)
462
463 try:
464 response = requests.get(url, headers=headers)
465 response.raise_for_status()
466 response_data = response.json()
467 exams = response_data.get("data", {}).get("exams", [])
468 #print(response.json())
469 for exam in exams:
470 exam_id = exam.get('id')
471 print(f"正在处理问题ID: {exam_id}")
472
473 # 这里是你提交答案的代码逻辑
474 url_submit_answer = "https://sg01.purcotton.com/api/answer/complete"
475 payload = {
476 "tid": tid, # 假设任务ID为14
477 "exam_id": exam_id,
478 "win": 1 # 假设标记为正确
479 }
480 submit_response = requests.post(url_submit_answer, headers=headers, json=payload)
481 submit_response.raise_for_status()
482
483 if submit_response.status_code == 200:
484 submit_response_data = submit_response.json()
485 #print(submit_response_data) # 打印完整的响应体
486
487 # 提取并打印get_water, complete_num, 和 box_id
488 get_water = submit_response_data.get("data", {}).get("get_water", 0)
489 complete_num = submit_response_data.get("data", {}).get("complete_num", 0)
490 box_id = submit_response_data.get("data", {}).get("box_id", 0)
491 print(f"获取水量:{get_water}, 完成数量:{complete_num}, 宝箱ID:{box_id}")
492
493 # 如果box_id大于0,则打开宝箱
494 if box_id > 0:
495 print(f"检测到宝箱ID: {box_id},尝试打开宝箱...")
496 url_open_box = "https://sg01.purcotton.com/api/answer/open-box"
497 box_payload = {"box_id": box_id}
498 box_response = requests.post(url_open_box, headers=headers, json=box_payload)
499 box_response.raise_for_status()
500
501 if box_response.status_code == 200:
502 box_response_data = box_response.json()
503 # print(f"宝箱 {box_id} 打开成功,响应内容:", box_response_data)
504 # 提取sy_water和get_water
505 sy_water = box_response_data.get("data", {}).get("sy_water", 0)
506 get_water = box_response_data.get("data", {}).get("get_water", 0)
507 print(f"宝箱 剩余水量:{sy_water}, 宝箱水量:{get_water}")
508
509
510 # 随机停止3-5秒
511 time.sleep(random.randint(3, 5))
512 except requests.exceptions.RequestException as e:
513 print(f"请求失败: {e}")
514
515
516def today_water(code, token):#

Callers 1

pdrwFunction · 0.85

Calls 5

create_headersFunction · 0.85
sleepMethod · 0.80
printFunction · 0.50
getMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected