score.py 667 B

123456789101112131415
  1. import requests
  2. from requests.cookies import RequestsCookieJar
  3. import json
  4. def get_score(cookies):
  5. jar = RequestsCookieJar()
  6. for cookie in cookies:
  7. jar.set(cookie['name'], cookie['value'])
  8. total = requests.get("https://pc-api.xuexi.cn/open/api/score/get", cookies=jar).content.decode("utf8")
  9. total = int(json.loads(total, encoding="utf8")["data"]["score"])
  10. each = requests.get("https://pc-api.xuexi.cn/open/api/score/today/queryrate", cookies=jar).content.decode("utf8")
  11. each = json.loads(each, encoding="utf8")["data"]
  12. each = [int(i["currentScore"]) for i in each if i["ruleId"] in [1, 2, 9, 1002, 1003]]
  13. return total, each