feat(route): add 法国国际广播电台滚动新闻 (#8533)
This commit is contained in:
@@ -924,6 +924,12 @@ pageClass: routes
|
||||
|
||||
<Route author="imgss" example="/dytt" path="/dytt" supportBT="1"/>
|
||||
|
||||
## 法国国际广播电台
|
||||
|
||||
### 滚动新闻
|
||||
|
||||
<Route author="nczitzk" example="/rfi/news" path="/rfi/news"/>
|
||||
|
||||
## 高清电台
|
||||
|
||||
### 最新电影
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/news': ['nczitzk'],
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.rfi.fr';
|
||||
const currentUrl = `${rootUrl}/cn/滚动新闻`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('.article__title')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}${item.parent().parent().attr('href')}`,
|
||||
pubDate: parseDate(item.prev().find('time').attr('datetime')),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.t-content__body').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '滚动新闻 - 法国国际广播电台',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'rfi.fr': {
|
||||
_name: '法国国际广播电台',
|
||||
'.': [
|
||||
{
|
||||
title: '滚动新闻',
|
||||
docs: 'https://docs.rsshub.app/multimedia.html#fa-guo-guo-ji-guang-bo-dian-tai-gun-dong-xin-wen',
|
||||
source: ['/'],
|
||||
target: '/rfi/news',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/news', require('./news'));
|
||||
};
|
||||
Reference in New Issue
Block a user