From 2b4e3c048ce5e871cce2a849fa269cfaceccbd14 Mon Sep 17 00:00:00 2001
From: Betta <21828604@qq.com>
Date: Wed, 20 Mar 2019 11:57:31 +0800
Subject: [PATCH] =?UTF-8?q?add=20gamersky=20and=20=E6=B8=B8=E7=A0=94?=
=?UTF-8?q?=E7=A4=BE=20(#1784)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[ADD]游民星空今日推荐rss
[ADD]游研社推游栏目rss
---
docs/README.md | 8 ++++
lib/router.js | 6 +++
lib/routes/gamersky/news.js | 44 ++++++++++++++++++++++
lib/routes/yystv/recommend.js | 69 +++++++++++++++++++++++++++++++++++
4 files changed, 127 insertions(+)
create mode 100644 lib/routes/gamersky/news.js
create mode 100644 lib/routes/yystv/recommend.js
diff --git a/docs/README.md b/docs/README.md
index f0331fad7..4ab8a452f 100755
--- a/docs/README.md
+++ b/docs/README.md
@@ -2570,6 +2570,14 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
+### 游民星空
+
+
+
+### 游研社
+
+
+
## 小说·文学·阅读
### 观止(每日一文)
diff --git a/lib/router.js b/lib/router.js
index 7bb76564a..5f9381cbd 100755
--- a/lib/router.js
+++ b/lib/router.js
@@ -1174,4 +1174,10 @@ router.get('/zjgsu/tzgg', require('./routes/universities/zjgsu/tzgg/scripts'));
router.get('/zjgsu/gsgg', require('./routes/universities/zjgsu/gsgg/scripts'));
router.get('/zjgsu/xszq', require('./routes/universities/zjgsu/xszq/scripts'));
+// gamersky
+router.get('/gamersky/news', require('./routes/gamersky/news'));
+
+// 游研社
+router.get('/yystv/recommend/', require('./routes/yystv/recommend'));
+
module.exports = router;
diff --git a/lib/routes/gamersky/news.js b/lib/routes/gamersky/news.js
new file mode 100644
index 000000000..f744361df
--- /dev/null
+++ b/lib/routes/gamersky/news.js
@@ -0,0 +1,44 @@
+const axios = require('../../utils/axios');
+const cheerio = require('cheerio');
+
+module.exports = async (ctx) => {
+ const response = await axios({
+ method: 'get',
+ url: 'https://www.gamersky.com/news/',
+ headers: {
+ Referer: 'https://www.gamersky.com/news/',
+ },
+ });
+
+ const data = response.data;
+ const $ = cheerio.load(data);
+
+ const out = $('.Mid2L_con li')
+ .slice(0, 10)
+ .map(function() {
+ const info = {
+ title: $(this)
+ .find('.tt')
+ .text(),
+ link: $(this)
+ .find('.tt')
+ .attr('href'),
+ pubDate: new Date(
+ $(this)
+ .find('.time')
+ .text()
+ ).toUTCString(),
+ description: $(this)
+ .find('.txt')
+ .text(),
+ };
+ return info;
+ })
+ .get();
+
+ ctx.state.data = {
+ title: '游民星空-今日推荐',
+ link: 'https://www.gamersky.com/news/',
+ item: out,
+ };
+};
diff --git a/lib/routes/yystv/recommend.js b/lib/routes/yystv/recommend.js
new file mode 100644
index 000000000..c7845d294
--- /dev/null
+++ b/lib/routes/yystv/recommend.js
@@ -0,0 +1,69 @@
+const axios = require('../../utils/axios');
+const cheerio = require('cheerio');
+const date = require('../../utils/date');
+
+module.exports = async (ctx) => {
+ const response = await axios({
+ method: 'get',
+ url: 'http://www.yystv.cn/b/recommend',
+ });
+
+ const data = response.data;
+ const $ = cheerio.load(data);
+
+ const first_part = $('.b-list-main-item')
+ .slice(0, 2)
+ .map(function() {
+ const info = {
+ title: $(this)
+ .find('.b-main-info-title')
+ .text(),
+ link:
+ 'http://www.yystv.cn' +
+ $(this)
+ .find('.b-main-info-title a')
+ .attr('href'),
+ pubDate: date(
+ $(this)
+ .find('.b-main-createtime')
+ .text()
+ ),
+ author: $(this)
+ .find('.b-author')
+ .text(),
+ };
+ return info;
+ })
+ .get();
+
+ const second_part = $('.b-list li')
+ .slice(0, 8)
+ .map(function() {
+ const info = {
+ title: $(this)
+ .find('.b-item-title')
+ .text(),
+ link:
+ 'http://www.yystv.cn' +
+ $(this)
+ .find('.b-item-title a')
+ .attr('href'),
+ pubDate: date(
+ $(this)
+ .find('.fl')
+ .text()
+ ),
+ author: $(this)
+ .find('.author-icon-list')
+ .text(),
+ };
+ return info;
+ })
+ .get();
+
+ ctx.state.data = {
+ title: '游研社-推游',
+ link: 'http://www.yystv.cn/b/recommend',
+ item: first_part.concat(second_part),
+ };
+};