feat(breaking change): 将新榜登录方式改为COOKIE登陆 (#5552)

旧新榜登录方式将无法使用。
This commit is contained in:
lessmoe 2020-08-30 11:07:48 +08:00 committed by GitHub
parent 4b0f50234b
commit 2ca56e8dc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 7 deletions

View File

@ -543,5 +543,4 @@ RSSHub 支持使用访问密钥 / 码,白名单和黑名单三种方式进行
- 新榜
- `NEWRANK_USERNAME`: 用户名
- `NEWRANK_PASSWORD`: 密码
- `NEWRANK_COOKIE`: 登陆后的 COOKIE 值,其中 token 是必要的,其他可删除

View File

@ -903,7 +903,7 @@ rule
## 新榜
::: warning 注意
部署时需要配置 NEWRANK_USERNAME、NEWRANK_PASSWORD,具体见部署文档
部署时需要配置 NEWRANK_COOKIE,具体见部署文档
请勿过高频抓取,新榜疑似对每天调用 token 总次数进行了限制,超限会报错
:::

View File

@ -157,8 +157,7 @@ const calculateValue = () => {
refresh_token: envs.XIAOYUZHOU_TOKEN,
},
newrank: {
username: envs.NEWRANK_USERNAME,
password: envs.NEWRANK_PASSWORD,
cookie: envs.NEWRANK_COOKIE,
},
};
};

View File

@ -1,11 +1,12 @@
const got = require('@/utils/got');
const utils = require('./utils');
const config = require('@/config').value;
module.exports = async (ctx) => {
const uid = ctx.params.dyid;
const nonce = utils.random_nonce(9);
const url_detail = 'https://xd.newrank.cn/xdnphb/nr/cloud/douyin/detail/aweme?xyz=' + utils.decrypt_douyin_detail_xyz(nonce) + '&nonce=' + nonce;
const cookie = await utils.getCookie(ctx);
const cookie = String(config.newrank.cookie);
const response_detail = await got({
method: 'post',
url: url_detail,

View File

@ -65,6 +65,7 @@ async function clearCookie(ctx) {
ctx.cache.set(newrank_cookie_token, null);
}
// 加了验证码失效了
async function getCookie(ctx) {
// Check if this key should be replace? every 30 times should be fine.
await shouldUpdateCookie(ctx);

View File

@ -1,5 +1,6 @@
const got = require('@/utils/got');
const utils = require('./utils');
const config = require('@/config').value;
module.exports = async (ctx) => {
const uid = ctx.params.wxid;
@ -9,7 +10,7 @@ module.exports = async (ctx) => {
url: 'https://www.newrank.cn/xdnphb/detail/v1/rank/article/lists',
headers: {
Connection: 'keep-alive',
Cookie: await utils.getCookie(ctx),
Cookie: String(config.newrank.cookie),
},
form: {
account: uid,