y1ndan / genshinhelper2

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

8.8 起获取不到实时便笺信息了 #41

Closed goreliu closed 2 years ago

goreliu commented 2 years ago

版本:2.1.1

cookie_token 正确的情况:

{'data': None, 'message': 'Please login', 'retcode': 10001}
Traceback (most recent call last):
  File "/home/goreliu/git/site/www/genshin/genshin.py", line 32, in <module>
    for e in daily_note['expeditions']:
KeyError: 'expeditions'

cookie_token 错误的情况:

2022-08-08 10:49:34 ERROR 登录失效,请重新登录
Traceback (most recent call last):
  File "/home/goreliu/git/site/www/genshin/genshin.py", line 23, in <module>
    for i in ys.roles_info:
  File "/usr/lib/python3.10/site-packages/genshinhelper/core.py", line 58, in roles_info
    raise GenshinHelperException(response.get('message'))
genshinhelper.exceptions.GenshinHelperException: 登录失效,请重新登录

今天凌晨一点多还是正常的。重新登录也无效(cookie_token 不会改变),不知道是接口改了还是什么原因。用同样的 cookie_token,每日签到是正常的。

y1ndan commented 2 years ago

根据群友测试是可以用的。应该是你的cookie问题。

goreliu commented 2 years ago

根据群友测试是可以用的。应该是你的cookie问题。

今天白天也正常吗?我又重新获取了一次不一样的 cookie_token,还是同样的错误,已经登录成功了:

{'region': 'cn_gf01', 'game_uid': 'xxx', 'nickname': 'xxx', 'level': 59, 'region_name': '天空岛'}

具体内容还是:

{'data': None, 'message': 'Please login', 'retcode': 10001}

另外每日签到是正常的,应该说明 cookie_token 没问题,如果别人的正常,只能是我米游社账号有问题了,但我两个账号都是这样的。

y1ndan commented 2 years ago

你把cookie格式发下

goreliu commented 2 years ago

你把cookie格式发下

import genshinhelper as gh

cookies = 'account_id=277609xxx; cookie_token=koyx2JIF3TRbRm3kpDsXaiVGhn7Bu82Kxx2sXXXX'

for cookie in gh.utils.get_cookies(cookies):
    ys = gh.YuanShen(cookie)

    i = ys.roles_info[0]
    print(i)
    print(ys.get_daily_note(i['game_uid'], i['region']))
2022-08-08 13:52:50 INFO Preparing to get user game roles information ...
{'region': 'cn_gf01', 'game_uid': '175603xxx', 'nickname': 'xxx', 'level': 59, 'region_name': '天空岛'}
2022-08-08 13:52:51 INFO Preparing to get Yuan Shen daily note ...
{'role_id': '175603xxx', 'server': 'cn_gf01'}
{'data': None, 'message': 'Please login', 'retcode': 10001}

我把 cn_gf01 改成别的也是同样的错误。

y1ndan commented 2 years ago

建议直接用成品

y1ndan commented 2 years ago

建议直接用成品

goreliu commented 2 years ago

我知道是怎么回事了,挂个代理后正常了,原来的 ip 被特别对待了。