mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 19:59:54 +08:00
feat(route): add 虎嗅 简报 (#10663)
* feat(route): add 虎嗅 简报 * Update lib/v2/huxiu/briefColumn.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix(route): get tittle * Update lib/v2/huxiu/briefColumn.js
This commit is contained in:
@@ -2310,6 +2310,10 @@ others = 热点新闻 + 滚动新闻
|
||||
|
||||
<Route author="AlexdanerZe" example="/huxiu/collection/212" path="/huxiu/collection/:id" :paramsDesc="['文集 id']" />
|
||||
|
||||
### 简报
|
||||
|
||||
<Route author="Fatpandac" example="/huxiu/briefcolumn/1" path="/huxiu/briefcolumn/:id" :paramsDesc="['简报 id']" />
|
||||
|
||||
## 互动吧
|
||||
|
||||
### 活动
|
||||
|
||||
51
lib/v2/huxiu/briefColumn.js
Normal file
51
lib/v2/huxiu/briefColumn.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const link = `https://api-brief.huxiu.com/briefColumn/getContentListByCategoryId`;
|
||||
const response = await got
|
||||
.post(link, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: `platform=www&brief_column_id=${id}&last_id=`,
|
||||
})
|
||||
.json();
|
||||
|
||||
const list = response.data.datalist;
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) => {
|
||||
const link = `https://www.huxiu.com/brief/${item.brief_id}`;
|
||||
|
||||
return ctx.cache.tryGet(link, async () => {
|
||||
const detailResponse = await got(link);
|
||||
const $ = cheerio.load(detailResponse.data);
|
||||
|
||||
const description = $('#js-part').html();
|
||||
|
||||
return {
|
||||
title: item.title,
|
||||
pubDate: item.format_publish_time.includes('前') ? parseRelativeDate(item.format_publish_time) : parseDate(item.format_publish_time),
|
||||
description,
|
||||
link,
|
||||
};
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
const title = async () => {
|
||||
const res = await got(`https://www.huxiu.com/briefColumn/${id}.html`);
|
||||
const $ = cheerio.load(res.data);
|
||||
|
||||
return $('#top > div:nth-child(1) > div > div.brief-content__name').text();
|
||||
};
|
||||
|
||||
ctx.state.data = {
|
||||
title: `虎嗅 - ${await title()}`,
|
||||
link: `https://www.huxiu.com/briefColumn/${id}.html`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -36,6 +36,12 @@ module.exports = {
|
||||
source: ['/collection/:id', '/'],
|
||||
target: (params) => `/huxiu/collection/${params.id.replace('.html', '')}`,
|
||||
},
|
||||
{
|
||||
title: '简报',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#hu-xiu',
|
||||
source: ['/briefColumn/:id', '/'],
|
||||
target: (params) => `/huxiu/briefcolumn/${params.id.replace('.html', '')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5,4 +5,5 @@ module.exports = (router) => {
|
||||
router.get('/moment', require('./moment'));
|
||||
router.get('/tag/:id', require('./tag'));
|
||||
router.get('/search/:keyword', require('./search'));
|
||||
router.get('/briefcolumn/:id', require('./briefColumn'));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user