mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
Added Radio Free Asia
This commit is contained in:
@@ -149,6 +149,18 @@ Generates full-text feeds that the official feed doesn't provide.
|
||||
|
||||
<RouteEn author="oppliate" example="/phoronix/news_topic/Intel" path="/phoronix/:page/:queryOrItem?" :paramsDesc="['Page name', 'For `category` it corresponds to `item`, for other pages it\'s `q`. You may find available parameters from their navigator links. E.g. to subscribe to the category page `https://www.phoronix.com/scan.php?page=category&item=Computers`, fill in the path `/phoronix/category/Computers`']" />
|
||||
|
||||
## Radio Free Asia (RFA)
|
||||
|
||||
<RouteEn author="zphw" example="/rfa/english" path="/rfa/:language?/:channel?/:subChannel?" :paramsDesc="['language, English by default', 'channel', 'subchannel, where applicable']" />
|
||||
|
||||
Delivers a better experience by supporting parameter specification.
|
||||
|
||||
Parameters can be obtained from the official website, for instance:
|
||||
|
||||
`https://www.rfa.org/cantonese/news` corresponds to `/rfa/cantonese/news`
|
||||
|
||||
`https://www.rfa.org/cantonese/news/htm` corresponds to `/rfa/cantonese/news/htm`
|
||||
|
||||
## Reuters
|
||||
|
||||
### Channel
|
||||
|
||||
@@ -965,3 +965,15 @@ category 对应的关键词有
|
||||
### 九江新闻
|
||||
|
||||
<Route author="jjlzg" example="/fjnews/jjnews" path="/fjnews/jjnews"/>
|
||||
|
||||
## 自由亚洲电台
|
||||
|
||||
<Route author="zphw" example="/rfa/mandarin" path="/rfa/:language?/:channel?/:subChannel?" :paramsDesc="['语言,默认 English', '频道', '子频道(如存在)']" />
|
||||
|
||||
通过指定频道参数,提供比官方源更佳的阅读体验。
|
||||
|
||||
参数均可在官网获取,如:
|
||||
|
||||
`https://www.rfa.org/cantonese/news` 对应 `/rfa/cantonese/news`
|
||||
|
||||
`https://www.rfa.org/cantonese/news/htm` 对应 `/rfa/cantonese/news/htm`
|
||||
|
||||
@@ -3780,4 +3780,7 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog'));
|
||||
// Caixin Latest
|
||||
router.get('/caixin/latest', require('./routes/caixin/latest'));
|
||||
|
||||
// Radio Free Asia
|
||||
router.get('/rfa/:language?/:channel?/:subChannel?', require('./routes/rfa/index'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
47
lib/routes/rfa/index.js
Normal file
47
lib/routes/rfa/index.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let url = 'https://www.rfa.org/' + (ctx.params.language || 'english');
|
||||
|
||||
if (ctx.params.channel) {
|
||||
url += '/' + ctx.params.channel;
|
||||
}
|
||||
if (ctx.params.subChannel) {
|
||||
url += '/' + ctx.params.subChannel;
|
||||
}
|
||||
|
||||
const response = await got.get(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const selectors = ['div[id=topstorywidefulltease]', 'div.two_featured', 'div.three_featured', 'div.single_column_teaser', 'div.sectionteaser', 'div.specialwrap'];
|
||||
const list = [];
|
||||
selectors.forEach(function (selector) {
|
||||
$(selector).each(function (_, e) {
|
||||
const item = {};
|
||||
item.title = $(e).find('h2 a span').first().text();
|
||||
item.link = $(e).find('h2 a').first().attr('href');
|
||||
list.push(item);
|
||||
});
|
||||
});
|
||||
|
||||
const result = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const content = await got.get(item.link);
|
||||
|
||||
const description = cheerio.load(content.data);
|
||||
item.description = description('div[id=storytext]').html();
|
||||
item.pubDate = new Date(description('span[id=story_date]').text()).toUTCString();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'RFA',
|
||||
link: 'https://www.rfa.org/',
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user