mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 04:11:26 +08:00
fix(route): 修复 newrank 列举公众号文章的 URL; 增加缺少的 n-token 参数; (#12262)
* fix(route): 修复 newrank 列举公众号文章的 URL; 增加缺少的 n-token 参数; 文档中说明必须自建 * fix(route): newrank: code review update * feat(route): 获取 newrank 得出的微信公众号链接的全文 * refactor: migrate to v2 ---------
This commit is contained in:
committed by
GitHub
parent
03f9a18146
commit
e66df707f9
@@ -1615,11 +1615,11 @@ rule
|
||||
|
||||
### 微信公众号
|
||||
|
||||
<Route author="lessmoe" example="/newrank/wechat/chijiread" path="/newrank/wechat/:wxid" :paramsDesc="['微信号,若微信号与新榜信息不一致,以新榜为准']" anticrawler="1"/>
|
||||
<Route author="lessmoe" example="/newrank/wechat/chijiread" path="/newrank/wechat/:wxid" :paramsDesc="['微信号,若微信号与新榜信息不一致,以新榜为准']" anticrawler="1" selfhost="1"/>
|
||||
|
||||
### 抖音短视频
|
||||
|
||||
<Route author="lessmoe" example="/newrank/douyin/110266463747" path="/newrank/douyin/:dyid" :paramsDesc="['抖音ID,可在新榜账号详情 URL 中找到']" anticrawler="1"/>
|
||||
<Route author="lessmoe" example="/newrank/douyin/110266463747" path="/newrank/douyin/:dyid" :paramsDesc="['抖音ID,可在新榜账号详情 URL 中找到']" anticrawler="1" selfhost="1"/>
|
||||
|
||||
::: warning 注意
|
||||
免费版账户抖音每天查询次数 20 次,如需增加次数可购买新榜会员或等待未来多账户支持
|
||||
|
||||
@@ -3005,8 +3005,8 @@ router.get('/liequtv/room/:id', lazyloadRouteHandler('./routes/liequtv/room'));
|
||||
router.get('/bwu/news', lazyloadRouteHandler('./routes/universities/bwu/news'));
|
||||
|
||||
// 新榜
|
||||
router.get('/newrank/wechat/:wxid', lazyloadRouteHandler('./routes/newrank/wechat'));
|
||||
router.get('/newrank/douyin/:dyid', lazyloadRouteHandler('./routes/newrank/douyin'));
|
||||
// router.get('/newrank/wechat/:wxid', lazyloadRouteHandler('./routes/newrank/wechat'));
|
||||
// router.get('/newrank/douyin/:dyid', lazyloadRouteHandler('./routes/newrank/douyin'));
|
||||
|
||||
// 漫小肆
|
||||
router.get('/manxiaosi/book/:id', lazyloadRouteHandler('./routes/manxiaosi/book'));
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const utils = require('./utils');
|
||||
const config = require('@/config').value;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const uid = ctx.params.wxid;
|
||||
const nonce = utils.random_nonce(9);
|
||||
const response = await got({
|
||||
method: 'post',
|
||||
url: 'https://www.newrank.cn/xdnphb/detail/v1/rank/article/lists',
|
||||
headers: {
|
||||
Connection: 'keep-alive',
|
||||
Cookie: String(config.newrank.cookie),
|
||||
},
|
||||
form: {
|
||||
account: uid,
|
||||
nonce,
|
||||
xyz: utils.decrypt_wechat_detail_xyz(uid, nonce),
|
||||
},
|
||||
});
|
||||
const name = response.data.value.user.name;
|
||||
const realTimeArticles = utils.flatten(response.data.value.realTimeArticles);
|
||||
const articles = utils.flatten(response.data.value.articles);
|
||||
const newArticles = realTimeArticles.concat(articles);
|
||||
const items = newArticles.map((item) => ({
|
||||
title: item.title,
|
||||
description: '',
|
||||
link: item.url,
|
||||
pubDate: item.publicTime,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: name + ' - 微信公众号',
|
||||
link: 'https://www.newrank.cn/new/readDetial?account=' + uid,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -3,10 +3,13 @@ const utils = require('./utils');
|
||||
const config = require('@/config').value;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.newrank || !config.newrank.cookie) {
|
||||
throw Error('newrank RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
|
||||
}
|
||||
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 = String(config.newrank.cookie);
|
||||
const cookie = config.newrank.cookie;
|
||||
const response_detail = await got({
|
||||
method: 'post',
|
||||
url: url_detail,
|
||||
4
lib/v2/newrank/maintainer.js
Normal file
4
lib/v2/newrank/maintainer.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
'/douyin/:dyid': ['lessmoe'],
|
||||
'/wechat/:wxid': ['lessmoe'],
|
||||
};
|
||||
15
lib/v2/newrank/radar.js
Normal file
15
lib/v2/newrank/radar.js
Normal file
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
'newrank.cn': {
|
||||
_name: '新榜',
|
||||
'.': [
|
||||
{
|
||||
title: '微信公众号',
|
||||
docs: 'https://docs.rsshub.app/social-media.html#xin-bang',
|
||||
},
|
||||
{
|
||||
title: '抖音短视频',
|
||||
docs: 'https://docs.rsshub.app/social-media.html#xin-bang',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
4
lib/v2/newrank/router.js
Normal file
4
lib/v2/newrank/router.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/douyin/:dyid', require('./douyin'));
|
||||
router.get('/wechat/:wxid', require('./wechat'));
|
||||
};
|
||||
65
lib/v2/newrank/wechat.js
Normal file
65
lib/v2/newrank/wechat.js
Normal file
@@ -0,0 +1,65 @@
|
||||
const got = require('@/utils/got');
|
||||
const { finishArticleItem } = require('@/utils/wechat-mp');
|
||||
const cheerio = require('cheerio');
|
||||
const utils = require('./utils');
|
||||
const config = require('@/config').value;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.newrank || !config.newrank.cookie) {
|
||||
throw Error('newrank RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
|
||||
}
|
||||
const uid = ctx.params.wxid;
|
||||
const nonce = utils.random_nonce(9);
|
||||
const { data: summaryHTML } = await got({
|
||||
method: 'get',
|
||||
url: `https://www.newrank.cn/new/readDetial?account=${uid}`,
|
||||
headers: {
|
||||
Connection: 'keep-alive',
|
||||
Cookie: config.newrank.cookie,
|
||||
},
|
||||
});
|
||||
const summary$ = cheerio.load(summaryHTML);
|
||||
const mainsrc = summary$('script')
|
||||
.toArray()
|
||||
.find((item) => (item.attribs.src || '').startsWith('/new/static/js/main.')).attribs.src;
|
||||
const { data: mainScript } = await got({
|
||||
method: 'get',
|
||||
url: `https://www.newrank.cn${mainsrc}`,
|
||||
});
|
||||
const N_TOKEN_match = mainScript.match(/"N-Token":"([^"]+)/);
|
||||
if (!N_TOKEN_match) {
|
||||
throw Error('Cannot find n-token');
|
||||
}
|
||||
const N_TOKEN = N_TOKEN_match[1];
|
||||
const response = await got({
|
||||
method: 'post',
|
||||
url: 'https://gw.newrank.cn/api/wechat/xdnphb/detail/v1/rank/article/lists',
|
||||
headers: {
|
||||
Connection: 'keep-alive',
|
||||
Cookie: config.newrank.cookie,
|
||||
'n-token': N_TOKEN,
|
||||
},
|
||||
form: {
|
||||
account: uid,
|
||||
nonce,
|
||||
xyz: utils.decrypt_wechat_detail_xyz(uid, nonce),
|
||||
},
|
||||
});
|
||||
const name = response.data.value.user.name;
|
||||
const realTimeArticles = utils.flatten(response.data.value.realTimeArticles);
|
||||
const articles = utils.flatten(response.data.value.articles);
|
||||
const newArticles = realTimeArticles.concat(articles);
|
||||
const items = newArticles.map((item) => ({
|
||||
title: item.title,
|
||||
description: '',
|
||||
link: item.url,
|
||||
pubDate: item.publicTime,
|
||||
}));
|
||||
await Promise.all(items.map((item) => finishArticleItem(ctx, item)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: name + ' - 微信公众号',
|
||||
link: `https://www.newrank.cn/new/readDetial?account=${uid}`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user