Closed YaoXuanZhi closed 2 years ago
这样可以阅读打包两不误
可以参考以下修改gk_apis.py文件的login方法,使用自定义的cookie 登录时,随意输入任意的手机号密码即可
@synchronized()
def _login(self) -> None:
"""登录"""
url = 'https://account.geekbang.org/account/ticket/login'
headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2', # noqa: E501
'Host': 'account.geekbang.org',
'Referer': 'https://account.geekbang.org/signin?redirect=https%3A%2F%2Fwww.geekbang.org%2F', # noqa: E501
}
data = {
"country": self._area,
"cellphone": self._account,
"password": self._password,
"captcha": "",
"remember": 1,
"platform": 3,
"appid": 1
}
# change code bellow
rawdata = 'your cookie string'
cookie = SimpleCookie()
cookie.load(rawdata)
# Even though SimpleCookie is dictionary-like, it internally uses a Morsel object
# which is incompatible with requests. Manually construct a dictionary instead.
cookies = {}
for key, morsel in cookie.items():
cookies[key] = morsel.value
# comment this line
# resp = self._post(url, data, headers=headers)
# use your own cookie
self._cookies = cookies
好的,我试下啦
这样可以阅读打包两不误