mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
Merge pull request #6587 from nczitzk/feature/cgtn
feat: add cgtn editors'pick
This commit is contained in:
@@ -79,6 +79,10 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more
|
||||
|
||||
<RouteEn author="nczitzk" example="/cgtn/top" path="/cgtn/top"/>
|
||||
|
||||
### Editors' Pick
|
||||
|
||||
<RouteEn author="nczitzk" example="/cgtn/pick" path="/cgtn/pick"/>
|
||||
|
||||
## China Labour Bulletin
|
||||
|
||||
### Commentary and Analysis
|
||||
|
||||
@@ -134,6 +134,10 @@ pageClass: routes
|
||||
|
||||
<Route author="nczitzk" example="/cgtn/top" path="/cgtn/top"/>
|
||||
|
||||
### Editors' Pick
|
||||
|
||||
<Route author="nczitzk" example="/cgtn/pick" path="/cgtn/pick"/>
|
||||
|
||||
## cnBeta
|
||||
|
||||
### 最新
|
||||
|
||||
@@ -3343,8 +3343,12 @@ router.get('/fulinian/:caty?', require('./routes/fulinian/index'));
|
||||
|
||||
// CGTN
|
||||
router.get('/cgtn/most/:type?/:time?', require('./routes/cgtn/most'));
|
||||
|
||||
router.get('/cgtn/pick', require('./routes/cgtn/pick'));
|
||||
|
||||
router.get('/cgtn/opinions', require('./routes/cgtn/opinions'));
|
||||
|
||||
|
||||
// AppSales
|
||||
router.get('/appsales/:caty?/:time?', require('./routes/appsales/index'));
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.cgtn.com/';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('.titleArea')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a');
|
||||
return {
|
||||
title: a.text(),
|
||||
link: a.attr('href'),
|
||||
pubDate: new Date(parseInt(a.attr('data-time'))).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('#cmsMainContent').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: "CGTN - Editors' Pick",
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user