Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookies 刷新意外 correspondPath 过期或错误 #976

Open
z0z0r4 opened this issue Feb 24, 2024 · 3 comments
Open

Cookies 刷新意外 correspondPath 过期或错误 #976

z0z0r4 opened this issue Feb 24, 2024 · 3 comments
Labels
账号相关/Account 接口:账号或登录 问题/Question 暂时无法确定的性质

Comments

@z0z0r4
Copy link
Collaborator

z0z0r4 commented Feb 24, 2024

Nemo2011/bilibili-api#687

之前一直都可以的,现在出问题了

@z0z0r4 z0z0r4 added 问题/Question 暂时无法确定的性质 账号相关/Account 接口:账号或登录 labels Feb 24, 2024
@z0z0r4 z0z0r4 changed the title Cookies 更新意外 correspondPath 过期或错误 Cookies 刷新意外 correspondPath 过期或错误 Feb 24, 2024
@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Feb 25, 2024

有谁遇到过的吗?

示例
pip install bilibili-api-python

from bilibili_api import Credential, sync
sync(Credential(sessdata="", bili_jct="", ac_time_value="").refresh())

这太大坨了,我实在抠不出来

@My-Responsitories
Copy link

没有, 这边依然正常刷新, 试试检查你的本地时间是否正确
示例:

import re
import time
import requests
from Crypto.Cipher import PKCS1_OAEP
from Crypto.PublicKey.RSA import RsaKey
from Crypto.Hash import SHA256

public_key = RsaKey(
    n=int('cb81dd8e02470656da04dd38544446e2a3412051cfe9adc6a330a5ef90228509684960970b91c3360ca29c49e1690ff8fa068cb9dfc6179d1e9585cb9424e847db1ef59f33e37dd4dca8ccfb7631ee9b4a92640d00c8204300152a0ab7cd802889d3445aec69918fe6022b534912e7b095be3424dad1ba81145e969b533181f1', 16),
    e=65537
)

def getCorrespondUrl(timestamp:int):
    data = f"refresh_{timestamp}".encode()
    encrypted = PKCS1_OAEP.new(public_key, hashAlgo=SHA256).encrypt(data)
    return f"https://www.bilibili.com/correspond/1/{encrypted.hex()}"


url = getCorrespondUrl(int(time.time() * 1000))
response = requests.get(url, headers={'user-agent': 'Mozilla/5.0'}, cookies={'SESSDATA': sess})
response.raise_for_status()
refresh_csrf = re.search(r'<div id="1-name">([0-9a-f]+)</div>', response.text).group(1)
print(refresh_csrf, len(refresh_csrf))
# *** 32

@z0z0r4
Copy link
Collaborator Author

z0z0r4 commented Feb 25, 2024

我现在也复现不出了...暂时搁置,看看我那边发 issue 的怎么说

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
账号相关/Account 接口:账号或登录 问题/Question 暂时无法确定的性质
Projects
None yet
Development

No branches or pull requests

2 participants