add nytimes morning post (#253)

This commit is contained in:
Yang Bin
2018-06-02 11:36:49 +08:00
committed by DIYgod
parent 4606696a0c
commit 8b490af03e
6 changed files with 66 additions and 1 deletions
+2
View File
@@ -127,6 +127,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- yande.re
- posts
- Popular Recent Posts
- 纽约时报
- 新闻早报
## 鸣谢
+16
View File
@@ -1030,3 +1030,19 @@ GitHub 官方也提供了一些 RSS:
since,时间跨度,可在 [Trending 页](https://github.com/trending/javascript?since=monthly) URL 中找到,可选 daily weekly monthly
language,语言,可在 [Trending 页](https://github.com/trending/javascript?since=monthly) URL 中找到
## 纽约时报
::: tip 提示
纽约时报 RSS: https://cn.nytimes.com/rss/
:::
### 新闻早报
举例: [https://rsshub.app/nytimes/morning_post](https://rsshub.app/nytimes/morning_post)
路由: `/nytimes/morning_post`
参数: 无
+1
View File
@@ -55,6 +55,7 @@
"path-to-regexp": "2.2.1",
"readall": "1.0.0",
"redis": "2.8.0",
"rss-parser": "^3.1.3",
"twit": "2.2.9",
"winston": "3.0.0-rc5"
},
+3
View File
@@ -272,4 +272,7 @@ router.get('/yande.re/post/popular_recent', require('./routes/yande.re/post_popu
router.get('/yande.re/post/:tags', require('./routes/yande.re/post'));
router.get('/yande.re/post/popular_recent/:period', require('./routes/yande.re/post_popular_recent'));
// nytimes
router.get('/nytimes/morning_post', require('./routes/nytimes/morning_post'));
module.exports = router;
+25
View File
@@ -0,0 +1,25 @@
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,
};
};
+19 -1
View File
@@ -6349,6 +6349,13 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
hash-base "^3.0.0"
inherits "^2.0.1"
rss-parser@^3.1.3:
version "3.1.3"
resolved "http://registry.npm.taobao.org/rss-parser/download/rss-parser-3.1.3.tgz#ad56491623d66ccce2f4f5c833377542c0f0c4f5"
dependencies:
entities "^1.1.1"
xml2js "^0.4.17"
run-async@^2.2.0:
version "2.3.0"
resolved "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0"
@@ -6395,7 +6402,7 @@ sax@0.5.x:
version "0.5.8"
resolved "https://registry.npmjs.org/sax/-/sax-0.5.8.tgz#d472db228eb331c2506b0e8c15524adb939d12c1"
sax@^1.2.4, sax@~1.2.1:
sax@>=0.6.0, sax@^1.2.4, sax@~1.2.1:
version "1.2.4"
resolved "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
@@ -7777,6 +7784,17 @@ xml-name-validator@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
xml2js@^0.4.17:
version "0.4.19"
resolved "http://registry.npm.taobao.org/xml2js/download/xml2js-0.4.19.tgz#686c20f213209e94abf0d1bcf1efaa291c7827a7"
dependencies:
sax ">=0.6.0"
xmlbuilder "~9.0.1"
xmlbuilder@~9.0.1:
version "9.0.7"
resolved "http://registry.npm.taobao.org/xmlbuilder/download/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d"
xtend@^4.0.0, xtend@~4.0.1:
version "4.0.1"
resolved "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"