mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(route): 36kr主题文章 (#10161)
* fix(route): 36kr主题文章 * fix: add fulltext
This commit is contained in:
+1
-1
@@ -54,7 +54,7 @@ pageClass: routes
|
||||
|
||||
### 主题文章
|
||||
|
||||
<Route author="nczitzk" example="/36kr/motif/452" path="/36kr/motif/:mid" :paramsDesc="['主题 ID']" />
|
||||
<Route author="nczitzk" example="/36kr/motif/452" path="/36kr/motif/:id" :paramsDesc="['主题 ID']" />
|
||||
|
||||
### 搜索文章
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module.exports = {
|
||||
'/motif/:mid': ['nczitzk'],
|
||||
'/motif/:id': ['nczitzk'],
|
||||
'/news/:category?': ['nczitzk'],
|
||||
'/newsflashes': ['hillerliao'],
|
||||
'/search/article/:keyword': ['xyqfer', 'kt286', 'nczitzk'],
|
||||
'/user/:uid': ['nczitzk'],
|
||||
'/user/:id': ['nczitzk'],
|
||||
};
|
||||
|
||||
+42
-21
@@ -1,36 +1,57 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const CryptoJS = require('crypto-js');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const motifUrl = `https://36kr.com/motif/${ctx.params.mid}`;
|
||||
const id = ctx.params.id;
|
||||
|
||||
const rootUrl = 'https://36kr.com';
|
||||
const currentUrl = `${rootUrl}/motif/${id}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: motifUrl,
|
||||
url: currentUrl,
|
||||
});
|
||||
const data = JSON.parse(response.data.match(/"motifDetailData":{"code":0,"data":(.*?)},"channel":/)[1]);
|
||||
|
||||
const motifInfo = data.motifInfo.data;
|
||||
const motifArticleList = data.motifArticleList.data.itemList;
|
||||
const articleList = motifArticleList.map((item) => ({
|
||||
const data = JSON.parse(response.data.match(/"motifDetailData":{"code":0,"data":(.*)},"channel"/)[1]);
|
||||
|
||||
let items = data.motifArticleList.data.itemList.map((item) => ({
|
||||
title: item.templateMaterial.widgetTitle,
|
||||
link: `https://36kr.com/${item.route.split('?')[0] === 'detail_video' ? 'video' : 'p'}/${item.itemId}`,
|
||||
link: `${rootUrl}/p/${item.itemId}`,
|
||||
pubDate: parseDate(item.templateMaterial.publishTime),
|
||||
}));
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const key = CryptoJS.enc.Utf8.parse('efabccee-b754-4c');
|
||||
const cipherText = detailResponse.data.match(/{"state":"(.*)","isEncrypt":true}/)[1];
|
||||
|
||||
const content = JSON.parse(
|
||||
CryptoJS.AES.decrypt(cipherText, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.Pkcs7,
|
||||
})
|
||||
.toString(CryptoJS.enc.Utf8)
|
||||
.toString()
|
||||
).articleDetail.articleDetailData.data;
|
||||
|
||||
item.author = content.author;
|
||||
item.description = content.widgetContent;
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `36氪专题 - ${motifInfo.categoryTitle}`,
|
||||
link: motifUrl,
|
||||
item: await Promise.all(
|
||||
articleList.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const contentResponse = await got({ method: 'get', url: item.link });
|
||||
const result = contentResponse.data.match(/"articleDetailData":(.*?),"articleRecommendData":/) || contentResponse.data.match(/"videoDetail":(.*?),"authorVideos":/);
|
||||
const contentData = JSON.parse(result[1]);
|
||||
item.description = contentData.data.widgetContent;
|
||||
return item;
|
||||
})
|
||||
)
|
||||
),
|
||||
description: motifInfo.categoryTitle,
|
||||
title: `36kr - ${data.motifInfo.data.categoryTitle}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/motif/:mid', require('./motif'));
|
||||
router.get('/motif/:id', require('./motif'));
|
||||
router.get('/news/:category?', require('./news'));
|
||||
router.get('/newsflashes', require('./newsflashes'));
|
||||
router.get('/search/article/:keyword', require('./search/article'));
|
||||
|
||||
Reference in New Issue
Block a user