feat(route): add 風傳媒 (#8319)
This commit is contained in:
parent
2aa3dd8f8b
commit
fafd9b8a18
|
|
@ -2874,6 +2874,26 @@ column 为 third 时可选的 category:
|
|||
|
||||
<Route author="LogicJake" example="/tencent/news/author/5933889" path="/tencent/news/author/:mid" :paramsDesc="['企鹅号 ID']"/>
|
||||
|
||||
## 風傳媒
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/storm" path="/storm/:category?/:id?" :paramsDesc="['分类,见下表,默认为新聞總覽']">
|
||||
|
||||
| 新聞總覽 | 地方新聞 | 歷史頻道 | 評論總覽 |
|
||||
| -------- | ------------- | -------- | ----------- |
|
||||
| articles | localarticles | history | all-comment |
|
||||
|
||||
::: tip 提示
|
||||
|
||||
支持形如 <https://www.storm.mg/category/118> 的路由,即 [`/storm/category/118`](https://rsshub.app/storm/category/118)
|
||||
|
||||
支持形如 <https://www.storm.mg/localarticle-category/s149845> 的路由,即 [`/storm/localarticle-category/s149845`](https://rsshub.app/storm/localarticle-category/s149845)
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 通識・現代中國
|
||||
|
||||
### 議題熱話
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'articles';
|
||||
const id = ctx.params.id ?? '';
|
||||
|
||||
const rootUrl = 'https://www.storm.mg';
|
||||
const currentUrl = `${rootUrl}/${category}${id ? `/${id}` : ''}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.link_title')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.attr('href'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('.notify_wordings').remove();
|
||||
content('#premium_block').remove();
|
||||
|
||||
item.description = content('#CMS_wrapper').html();
|
||||
item.author = content('meta[property="dable:author"]').attr('content');
|
||||
item.pubDate = parseDate(content('meta[itemprop="datePublished"]').attr('content'));
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:category?/:id?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'storm.mg': {
|
||||
_name: '風傳媒',
|
||||
'.': [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#feng-chuan-mei',
|
||||
source: ['/:category/:id'],
|
||||
target: '/storm/:category?/:id?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/:category?/:id?', require('./index'));
|
||||
};
|
||||
Loading…
Reference in New Issue