mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-29 18:06:31 +08:00
fix(route): 36kr用户文章 (#10092)
This commit is contained in:
+1
-1
@@ -50,7 +50,7 @@ pageClass: routes
|
||||
|
||||
### 用户文章
|
||||
|
||||
<Route author="nczitzk" example="/36kr/user/747305693" path="/36kr/user/:uid" :paramsDesc="['用户 ID']" />
|
||||
<Route author="nczitzk" example="/36kr/user/747305693" path="/36kr/user/:id" :paramsDesc="['用户 ID']" />
|
||||
|
||||
### 主题文章
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@ module.exports = (router) => {
|
||||
router.get('/news/:category?', require('./news'));
|
||||
router.get('/newsflashes', require('./newsflashes'));
|
||||
router.get('/search/article/:keyword', require('./search/article'));
|
||||
router.get('/user/:uid', require('./user'));
|
||||
router.get('/user/:id', require('./user'));
|
||||
};
|
||||
|
||||
+49
-24
@@ -2,35 +2,60 @@ const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const userUrl = `https://36kr.com/user/${ctx.params.uid}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: userUrl,
|
||||
});
|
||||
const data = JSON.parse(response.data.match(/"authorDetailData":(.*?),"channel":/)[1]);
|
||||
const id = ctx.params.id;
|
||||
|
||||
const authorInfo = data.authorInfo.data;
|
||||
const authorFlowList = data.authorFlowList.data.itemList;
|
||||
const articleList = authorFlowList.map((item) => ({
|
||||
const rootUrl = 'https://36kr.com';
|
||||
const apiRootUrl = 'https://gateway.36kr.com';
|
||||
const currentUrl = `${rootUrl}/user/${id}`;
|
||||
|
||||
const infoResponse = await got({
|
||||
method: 'post',
|
||||
url: `${apiRootUrl}/api/mis/user/info`,
|
||||
json: {
|
||||
param: {
|
||||
userId: id,
|
||||
siteId: 1,
|
||||
platformId: 2,
|
||||
},
|
||||
platformId: 2,
|
||||
siteId: 1,
|
||||
userId: id,
|
||||
partner_id: 'web',
|
||||
},
|
||||
});
|
||||
|
||||
const response = await got({
|
||||
method: 'post',
|
||||
url: `${apiRootUrl}/api/mis/me/article`,
|
||||
json: {
|
||||
param: {
|
||||
userId: id,
|
||||
pageEvent: 0,
|
||||
pageSize: 20,
|
||||
pageCallback: '',
|
||||
siteId: 1,
|
||||
platformId: 2,
|
||||
},
|
||||
pageCallback: '',
|
||||
pageEvent: 0,
|
||||
pageSize: 20,
|
||||
platformId: 2,
|
||||
siteId: 1,
|
||||
userId: id,
|
||||
partner_id: 'web',
|
||||
},
|
||||
});
|
||||
|
||||
const items = response.data.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),
|
||||
description: `<p>${item.templateMaterial.widgetContent}</p>`,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `36氪用户 - ${authorInfo.userNick}`,
|
||||
link: userUrl,
|
||||
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: `${authorInfo.label} | ${authorInfo.summary}`,
|
||||
title: `36kr - ${infoResponse.data.data.userNick}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user