Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

关于如何使用login中的login_with_captcha()函数的问题 #112

Open
dakeke675378524 opened this issue Aug 13, 2018 · 2 comments

Comments

@dakeke675378524
Copy link

dakeke675378524 commented Aug 13, 2018

为什么我正确地输入了用户名和密码,然而却返回的用户名与密码不对啊?

`
from bilibili import bilibili
from printer import Printer
import base64
import configloader
import requests

username = '13408667618'
password = '13977586531W'

headers = {
'Accept': 'application/json, text/plain, /',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
'Host': 'passport.bilibili.com',
'cookie': "sid=hxt5szbb"
}
s = requests.session()
url = "https://passport.bilibili.com/captcha"
res = s.get(url, headers=headers) # 用于获取验证码图片
tmp1 = base64.b64encode(res.content)
captcha = bilibili().cnn_captcha(tmp1)
temp_params = 'actionKey=' + bilibili().dic_bilibili[
'actionKey'] + '&appkey=' + bilibili().dic_bilibili['appkey'] + '&build=' + bilibili().dic_bilibili[
'build'] + '&captcha=' + captcha + '&device=' + bilibili().dic_bilibili[
'device'] + '&mobi_app=' +
bilibili().dic_bilibili['mobi_app'] + '&password=' + password + '&platform=' +
bilibili().dic_bilibili[
'platform'] + '&username=' + username
sign = bilibili().calc_sign(temp_params)
payload = temp_params + '&sign=' + sign
headers['Content-type'] = "application/x-www-form-urlencoded"
headers['cookie'] = "sid=hxt5szbb"
url = "https://passport.bilibili.com/api/v2/oauth2/login"
response = s.post(url, data=payload, headers=headers)
print(response.text)
print(response.json())
`

这个运行之后返回的结果是
此次登录出现验证码,识别结果为2B4MN {"ts":1534167028,"code":-629,"message":"账号或者密码错误"} {'ts': 1534167028, 'code': -629, 'message': '账号或者密码错误'}

求问一下问题在哪里。。。

@Dawnnnnnn
Copy link
Owner

password参数需要加密,不是简单的拼接就行的,加密方法是先获取一个key和rsa公钥,然后加密密码,具体可以看看代码实现

@yjqiang
Copy link
Collaborator

yjqiang commented Aug 13, 2018

请及时把自己的密码修改掉,这是公开issue,所有人均可见

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants