feat(route): caixin weekly (#13017)
This commit is contained in:
parent
69512f081e
commit
24159b44ee
|
|
@ -573,13 +573,15 @@ Category 列表:
|
|||
|
||||
### 财新一线
|
||||
|
||||
<Route author="boypt" example="/caixin/k" path="/caixin/k" radar="1" supportPodcast="1"/>
|
||||
<Route author="boypt" example="/caixin/k" path="/caixin/k" radar="1" supportPodcast="1"/>
|
||||
|
||||
## 参考消息
|
||||
|
||||
### 栏目
|
||||
|
||||
<Route author="yuxinliu-alex nczitzk" example="/cankaoxiaoxi/column/diyi" path="/cankaoxiaoxi/column/:id?" :paramsDesc="['栏目 id,默认为 diyi,即第一关注']">
|
||||
<Route author="yuxinliu-alex nczitzk" example="/cankaoxiaoxi/column/diyi" path="/cankaoxiaoxi/column/:id?" :paramsDesc="['栏目 id,默认为 `diyi`,即第一关注']">
|
||||
|
||||
::: details 栏目
|
||||
|
||||
| 栏目 | id |
|
||||
| -------------- | -------- |
|
||||
|
|
@ -603,8 +605,14 @@ Category 列表:
|
|||
| 军事 | junshi |
|
||||
| 参考人物 | cankaorw |
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
### 财新周刊
|
||||
|
||||
<Route author="TonyRL" example="/caixin/weekly" path="/caixin/weekly" radar="1" rssbud="1"/>
|
||||
|
||||
## 朝日新聞中文網(繁體中文版)
|
||||
|
||||
::: tip 提示
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@ module.exports = {
|
|||
'/database': ['nczitzk'],
|
||||
'/k': ['boypt'],
|
||||
'/latest': ['tpnonthealps'],
|
||||
'/weekly': ['TonyRL'],
|
||||
'/:column/:category': ['idealclover'],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,5 +39,13 @@ module.exports = {
|
|||
target: '/caixin/database',
|
||||
},
|
||||
],
|
||||
weekly: [
|
||||
{
|
||||
title: '财新周刊',
|
||||
docs: 'https://docs.rsshub.app/traditional-media.html#cai-xin-wang',
|
||||
source: ['/', '/*'],
|
||||
target: '/caixin/weekly',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@ module.exports = (router) => {
|
|||
router.get('/database', require('./database'));
|
||||
router.get('/k', require('./k'));
|
||||
router.get('/latest', require('./latest'));
|
||||
router.get('/weekly', require('./weekly'));
|
||||
router.get('/:column/:category', require('./category'));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'https://weekly.caixin.com';
|
||||
|
||||
const { data: response } = await got(link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const list = $('.mi')
|
||||
.toArray()
|
||||
.map((item) => ({
|
||||
link: $(item).find('a').attr('href'),
|
||||
}))
|
||||
.concat(
|
||||
$('.xsjCon a')
|
||||
.toArray()
|
||||
.map((item) => ({
|
||||
link: $(item).attr('href'),
|
||||
}))
|
||||
)
|
||||
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit, 10) : 10);
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data } = await got(item.link);
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
item.title = $('head title').text();
|
||||
item.pubDate = parseDate(
|
||||
$('.source')
|
||||
.text()
|
||||
.match(/出版日期:(\d{4}-\d{2}-\d{2})/)[1]
|
||||
);
|
||||
|
||||
$('.subscribe').remove();
|
||||
|
||||
const report = $('.report');
|
||||
report.find('.title, .source, .date').remove();
|
||||
|
||||
item.description = $('.cover').html() + report.html() + $('.magIntro2').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('head title').text(),
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue