From c63bc208945828a920772837eb2664b4ca882fa3 Mon Sep 17 00:00:00 2001 From: alphardex <2582347430@qq.com> Date: Thu, 30 Aug 2018 10:27:24 +0800 Subject: [PATCH 1/4] =?UTF-8?q?Add=20=E6=9E=9C=E5=A3=B3=E7=BD=91=20--=20?= =?UTF-8?q?=E7=A7=91=E5=AD=A6=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++-- docs/README.md | 10 ++++++++++ guokr/scientific.js | 19 +++++++++++++++++++ router.js | 3 +++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 guokr/scientific.js diff --git a/README.md b/README.md index 675318e1d..cf5b85772 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 上海微系统与信息技术研究所学术活动 - ifanr - AppSolution +- 果壳网 + - 科学人 @@ -320,9 +322,9 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 1. 在 [/router.js](https://github.com/DIYgod/RSSHub/blob/master/router.js) 里添加路由 -1. 在 [/routes/](https://github.com/DIYgod/RSSHub/tree/master/routes) 中的路由对应路径添加获取 RSS 内容的脚本 +2. 在 [/routes/](https://github.com/DIYgod/RSSHub/tree/master/routes) 中的路由对应路径添加获取 RSS 内容的脚本 -1. 更新 README 和文档: [/README.md](https://github.com/DIYgod/RSSHub/blob/master/README.md) [/docs/README.md](https://github.com/DIYgod/RSSHub/blob/master/docs/README.md) +3. 更新 README 和文档: [/README.md](https://github.com/DIYgod/RSSHub/blob/master/README.md) [/docs/README.md](https://github.com/DIYgod/RSSHub/blob/master/docs/README.md) ### 参与讨论 diff --git a/docs/README.md b/docs/README.md index cb4f43b8b..47a2ed11a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2266,3 +2266,13 @@ type,分类 路由: `/ifanr/appso` 参数: 无 + +## 果壳网 guokr + +### 科学人 + +举例: + +路由: `/guokr/scientific` + +参数: 无 diff --git a/guokr/scientific.js b/guokr/scientific.js new file mode 100644 index 000000000..353c1c570 --- /dev/null +++ b/guokr/scientific.js @@ -0,0 +1,19 @@ +const axios = require('../../utils/axios'); + +module.exports = async (ctx) => { + const response = await axios.get('https://www.guokr.com/apis/minisite/article.json?retrieve_type=by_subject&limit=20&offset=0'); + + const result = response.data.result; + + ctx.state.data = { + title: '果壳网 科学人', + link: 'https://www.guokr.com/scientific', + description: '果壳网 科学人', + item: result.map((item) => ({ + title: item.title, + description: `item.summary
`, + pubDate: item.date_published, + link: item.url + })) + }; +}; diff --git a/router.js b/router.js index 29f7c7d00..ead30a735 100755 --- a/router.js +++ b/router.js @@ -488,4 +488,7 @@ router.get('/cas/sim/academic', require('./routes/cas/sim/academic')); // ifanr router.get('/ifanr/appso', require('./routes/ifanr/appso')); +// 果壳网 +router.get('/guokr/scientific', require('./routes/guokr/scientific')) + module.exports = router; From 0e6cc1460220fc068603f2342b230662dd6b733d Mon Sep 17 00:00:00 2001 From: alphardex <2582347430@qq.com> Date: Thu, 30 Aug 2018 16:49:00 +0800 Subject: [PATCH 2/4] run 'npm run format' --- router.js | 2 +- {guokr => routes/guokr}/scientific.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename {guokr => routes/guokr}/scientific.js (93%) diff --git a/router.js b/router.js index ead30a735..5d093a8ed 100755 --- a/router.js +++ b/router.js @@ -489,6 +489,6 @@ router.get('/cas/sim/academic', require('./routes/cas/sim/academic')); router.get('/ifanr/appso', require('./routes/ifanr/appso')); // 果壳网 -router.get('/guokr/scientific', require('./routes/guokr/scientific')) +router.get('/guokr/scientific', require('./routes/guokr/scientific')); module.exports = router; diff --git a/guokr/scientific.js b/routes/guokr/scientific.js similarity index 93% rename from guokr/scientific.js rename to routes/guokr/scientific.js index 353c1c570..e65e7ccb8 100644 --- a/guokr/scientific.js +++ b/routes/guokr/scientific.js @@ -13,7 +13,7 @@ module.exports = async (ctx) => { title: item.title, description: `item.summary
`, pubDate: item.date_published, - link: item.url - })) + link: item.url, + })), }; }; From 2219b117757b1bfae6d4e48930a2c07d2e994b61 Mon Sep 17 00:00:00 2001 From: alphardex <2582347430@qq.com> Date: Thu, 30 Aug 2018 21:59:33 +0800 Subject: [PATCH 3/4] fix description --- routes/guokr/scientific.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/guokr/scientific.js b/routes/guokr/scientific.js index e65e7ccb8..340b28648 100644 --- a/routes/guokr/scientific.js +++ b/routes/guokr/scientific.js @@ -11,7 +11,7 @@ module.exports = async (ctx) => { description: '果壳网 科学人', item: result.map((item) => ({ title: item.title, - description: `item.summary
`, + description: `${item.summary}
`, pubDate: item.date_published, link: item.url, })), From 1c1b060e248462d67d5a10b0447dd700e1c07348 Mon Sep 17 00:00:00 2001 From: alphardex <2582347430@qq.com> Date: Fri, 28 Sep 2018 21:50:38 +0800 Subject: [PATCH 4/4] =?UTF-8?q?add=20=E8=B6=A3=E5=A4=B4=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ docs/README.md | 16 ++++++++++++++++ router.js | 3 +++ routes/qutoutiao/category.js | 20 ++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 routes/qutoutiao/category.js diff --git a/README.md b/README.md index cf5b85772..03245b1e1 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - AppSolution - 果壳网 - 科学人 +- 趣头条 + - 分类 diff --git a/docs/README.md b/docs/README.md index 47a2ed11a..68e749cd8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2276,3 +2276,19 @@ type,分类 路由: `/guokr/scientific` 参数: 无 + +## 趣头条 + +### 分类 + +举例: [https://rsshub.app/qutoutiao/category/1](https://rsshub.app/qutoutiao/category/1) + +路由: `/qutoutiao/category/:cid` + +参数: cid,分类 id + +| 推荐 | 热点 | 娱乐 | 健康 | 养生 | 励志 | 科技 | ... | +| ---- | ---- | ---- | ---- | ---- | ---- | ---- | --- | +| 255 | 1 | 6 | 42 | 5 | 4 | 7 | ... | + +更多的 cid 可通过访问[官网](http://home.qutoutiao.net)切换分类,观察 url 获得。 diff --git a/router.js b/router.js index 5d093a8ed..ceb6ae24a 100755 --- a/router.js +++ b/router.js @@ -491,4 +491,7 @@ router.get('/ifanr/appso', require('./routes/ifanr/appso')); // 果壳网 router.get('/guokr/scientific', require('./routes/guokr/scientific')); +// 趣头条 +router.get('/qutoutiao/category/:cid', require('./routes/qutoutiao/category')); + module.exports = router; diff --git a/routes/qutoutiao/category.js b/routes/qutoutiao/category.js new file mode 100644 index 000000000..b5161f4a3 --- /dev/null +++ b/routes/qutoutiao/category.js @@ -0,0 +1,20 @@ +const axios = require('../../utils/axios'); + +module.exports = async (ctx) => { + const cid = ctx.params.cid; + const url = `http://api.1sapp.com/content/outList?cid=${cid}&tn=1&page=1&limit=10`; + const response = await axios.get(url); + const result = response.data.data.data; + + ctx.state.data = { + title: '趣头条', + link: 'http://home.qutoutiao.net', + description: '趣头条', + item: result.map((item) => ({ + title: item.title, + description: `${item.introduction}
`, + pubDate: new Date(item.show_time * 1000).toGMTString(), + link: item.url, + })), + }; +};