y1ndan / genshinhelper2

A Python library for miHoYo bbs and HoYoLAB Community. genshin 原神签到小助手 树脂提醒 微博超话 米游社米游币 崩坏3
https://www.yindan.me
GNU General Public License v3.0
534 stars 238 forks source link

在一台被米游社API屏蔽的VPS上光速签到 #7

Open Arondight opened 2 years ago

Arondight commented 2 years ago
2021-12-26 10:58:58 INFO Preparing to send notification ...
2021-12-26 10:58:58 INFO End of process run
2021-12-26 10:58:58 INFO Preparing to get user game roles information ...
2021-12-26 10:58:58 INFO Preparing to get Yuan Shen daily note ...
Traceback (most recent call last):
  File "/app/./genshincheckinhelper/main.py", line 399, in <module>
    main()
  File "/app/./genshincheckinhelper/main.py", line 388, in main
    run_once()
  File "/app/./genshincheckinhelper/main.py", line 384, in run_once
    job2()
  File "/app/./genshincheckinhelper/main.py", line 303, in job2
    daily_note = ys.get_daily_note(i['game_uid'], i['region'])
  File "/usr/local/lib/python3.10/site-packages/genshinhelper/mihoyo.py", line 90, in get_daily_note
    response = request('get', url, headers=get_headers(with_ds=True, new_ds=True, params=payload), params=payload, cookies=self.cookie).json()
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 910, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2021-12-26 10:58:59 INFO 

这个异常没 catch

Arondight commented 2 years ago

在被屏蔽的 IP 上访问某些 API 不会得到一个 JSON ,而是会得到一个 HTML,所以你需要在处理 JSON 的地方 catch 一个异常,详见 https://github.com/Arondight/Adachi-BOT/issues/520#issuecomment-1000664445