feat(route): add 法国国际广播电台滚动新闻 (#8533)

This commit is contained in:
Ethan Shen
2021-11-27 09:02:51 +00:00
committed by GitHub
parent 57a86c6f34
commit 3c432eb7e0
5 changed files with 74 additions and 0 deletions
+6
View File
@@ -924,6 +924,12 @@ pageClass: routes
<Route author="imgss" example="/dytt" path="/dytt" supportBT="1"/>
## 法国国际广播电台
### 滚动新闻
<Route author="nczitzk" example="/rfi/news" path="/rfi/news"/>
## 高清电台
### 最新电影
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/news': ['nczitzk'],
};
+49
View File
@@ -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,
};
};
+13
View File
@@ -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',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/news', require('./news'));
};