+6
-2
@@ -1512,13 +1512,17 @@ Category 列表:
|
||||
|
||||
### 纽约时报
|
||||
|
||||
<route name="全球纵览" author="HenryQW" example="/nytimes" path="/nytimes/index">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
纽约时报 RSS: https://cn.nytimes.com/rss/
|
||||
由于众所周知的原因,文章内的图片在中国大陆可能无法正常显示。
|
||||
|
||||
:::
|
||||
|
||||
<route name="新闻早报" author="yangkghjh" example="/nytimes/morning_post" path="/nytimes/morning_post"/>
|
||||
通过提取文章全文,以提供比官方源更佳的阅读体验。
|
||||
|
||||
</route>
|
||||
|
||||
### 新京报
|
||||
|
||||
|
||||
@@ -322,7 +322,7 @@ router.get('/yande.re/post/popular_recent', require('./routes/yande.re/post_popu
|
||||
router.get('/yande.re/post/popular_recent/:period', require('./routes/yande.re/post_popular_recent'));
|
||||
|
||||
// 纽约时报
|
||||
router.get('/nytimes/morning_post', require('./routes/nytimes/morning_post'));
|
||||
router.get('/nytimes', require('./routes/nytimes/index'));
|
||||
|
||||
// 3dm
|
||||
router.get('/3dm/:name/:type', require('./routes/3dm/game'));
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const utils = require('./utils');
|
||||
const Parser = require('rss-parser');
|
||||
const parser = new Parser();
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const feed = await parser.parseURL('https://cn.nytimes.com/rss/');
|
||||
const items = await Promise.all(
|
||||
feed.items.splice(0, 10).map(async (item) => {
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const description = utils.ProcessFeed(response.data);
|
||||
|
||||
const single = {
|
||||
title: item.title,
|
||||
description,
|
||||
pubDate: item.pubDate,
|
||||
link: item.link,
|
||||
author: item['dc:creator'],
|
||||
};
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '纽约时报中文网 国际纵览',
|
||||
link: 'https://cn.nytimes.com',
|
||||
description: '纽约时报中文网 国际纵览',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -1,25 +0,0 @@
|
||||
const Parser = require('rss-parser');
|
||||
const parser = new Parser();
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const feed = await parser.parseURL('https://cn.nytimes.com/rss/');
|
||||
const items = [];
|
||||
feed.items.forEach((item) => {
|
||||
if (item.title.startsWith('早报:')) {
|
||||
items.push({
|
||||
title: item.title,
|
||||
description: item.content,
|
||||
pubDate: item.pubDate,
|
||||
guid: item.guid,
|
||||
link: item.link,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: '纽约时报 新闻早报',
|
||||
link: encodeURI('https://cn.nytimes.com/search?query=%E6%97%A9%E6%8A%A5&lang=&dt=json&from=0&size=10'),
|
||||
description: '纽约时报 新闻早报',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const ProcessFeed = (data) => {
|
||||
const $ = cheerio.load(data);
|
||||
const content = $('section.article-body');
|
||||
|
||||
// remove useless DOMs
|
||||
content.find('div.big_ad, div.article-body-aside').each((i, e) => {
|
||||
$(e).remove();
|
||||
});
|
||||
|
||||
if ($('figure.article-span-photo').length > 0) {
|
||||
// there is a cover photo
|
||||
const cover = $('figure.article-span-photo');
|
||||
$(cover).insertBefore(content[0].firstChild);
|
||||
}
|
||||
|
||||
if ($('footer.author-info').length > 0) {
|
||||
// credit to original author and translators
|
||||
const footer = $('footer.author-info');
|
||||
$(footer).insertAfter(content[0].lastChild);
|
||||
}
|
||||
|
||||
return content.html();
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
ProcessFeed,
|
||||
};
|
||||
Reference in New Issue
Block a user