From da72f7f02f0eb085a477a279dd8b4d219056ae39 Mon Sep 17 00:00:00 2001
From: Betta <21828604@qq.com>
Date: Sun, 24 Mar 2019 22:26:05 +0800
Subject: [PATCH] add psnine (#1816)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[ADD]添加psnine rss: https://github.com/DIYgod/RSSHub/issues/1319
[CHA]修改游研社接口: 将原来的一个接口改为通用订阅接口
---
docs/README.md | 14 ++++++-
lib/router.js | 9 ++++-
lib/routes/psnine/game.js | 47 ++++++++++++++++++++++++
lib/routes/psnine/index.js | 43 ++++++++++++++++++++++
lib/routes/psnine/news.js | 42 +++++++++++++++++++++
lib/routes/psnine/shuzhe.js | 45 +++++++++++++++++++++++
lib/routes/psnine/trade.js | 49 +++++++++++++++++++++++++
lib/routes/yystv/category.js | 71 ++++++++++++++++++++++++++++++++++++
8 files changed, 318 insertions(+), 2 deletions(-)
create mode 100644 lib/routes/psnine/game.js
create mode 100644 lib/routes/psnine/index.js
create mode 100644 lib/routes/psnine/news.js
create mode 100644 lib/routes/psnine/shuzhe.js
create mode 100644 lib/routes/psnine/trade.js
create mode 100644 lib/routes/yystv/category.js
diff --git a/docs/README.md b/docs/README.md
index ccea88eb7..40e650bc1 100755
--- a/docs/README.md
+++ b/docs/README.md
@@ -2618,7 +2618,19 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
### 游研社
-
+
+
+| 推游 | 游戏史 | 大事件 | 文化 | 趣闻 | 经典回顾 |
+| --------- | ------- | ------ | ------- | ---- | -------- |
+| recommend | history | big | culture | news | retro |
+
+### psnine
+
+
+
+
+
+
## 小说·文学·阅读
diff --git a/lib/router.js b/lib/router.js
index 9762f251c..43925dace 100755
--- a/lib/router.js
+++ b/lib/router.js
@@ -1192,7 +1192,14 @@ router.get('/people/opinion/:id', require('./routes/people/opinion'));
router.get('/gamersky/news', require('./routes/gamersky/news'));
// 游研社
-router.get('/yystv/recommend/', require('./routes/yystv/recommend'));
+router.get('/yystv/category/:category', require('./routes/yystv/category'));
+
+// psnine
+router.get('/psnine/index', require('./routes/psnine/index'));
+router.get('/psnine/shuzhe', require('./routes/psnine/shuzhe'));
+router.get('/psnine/trade', require('./routes/psnine/trade'));
+router.get('/psnine/game', require('./routes/psnine/game'));
+router.get('/psnine/news', require('./routes/psnine/news'));
// 浙江大学
router.get('/zju/physics/:type', require('./routes/universities/zju/physics'));
diff --git a/lib/routes/psnine/game.js b/lib/routes/psnine/game.js
new file mode 100644
index 000000000..e115a51d4
--- /dev/null
+++ b/lib/routes/psnine/game.js
@@ -0,0 +1,47 @@
+const axios = require('../../utils/axios');
+const cheerio = require('cheerio');
+const date = require('../../utils/date');
+
+module.exports = async (ctx) => {
+ const url = 'https://www.psnine.com/psngame';
+ const response = await axios({
+ method: 'get',
+ url: url,
+ });
+
+ const data = response.data;
+ const $ = cheerio.load(data);
+
+ const out = $('table tr')
+ .map(function() {
+ const info = {
+ title: $(this)
+ .find('.title a')
+ .text(),
+ link: $(this)
+ .find('.title a')
+ .attr('href'),
+ pubDate: date(
+ $(this)
+ .find('.meta')
+ .text()
+ ),
+ description:
+ $(this)
+ .find('.title span')
+ .text() +
+ ' ' +
+ $(this)
+ .find('.twoge')
+ .text(),
+ };
+ return info;
+ })
+ .get();
+
+ ctx.state.data = {
+ title: 'psnine-' + $('title').text(),
+ link: 'https://www.psnine.com/',
+ item: out,
+ };
+};
diff --git a/lib/routes/psnine/index.js b/lib/routes/psnine/index.js
new file mode 100644
index 000000000..5720f542a
--- /dev/null
+++ b/lib/routes/psnine/index.js
@@ -0,0 +1,43 @@
+const axios = require('../../utils/axios');
+const cheerio = require('cheerio');
+const date = require('../../utils/date');
+
+module.exports = async (ctx) => {
+ const url = 'https://www.psnine.com/';
+ const response = await axios({
+ method: 'get',
+ url: url,
+ });
+
+ const data = response.data;
+ const $ = cheerio.load(data);
+
+ const out = $('.list li')
+ .slice(0, 20)
+ .map(function() {
+ const info = {
+ title: $(this)
+ .find('.title')
+ .text(),
+ link: $(this)
+ .find('.title a')
+ .attr('href'),
+ pubDate: date(
+ $(this)
+ .find('.meta')
+ .text()
+ ),
+ author: $(this)
+ .find('.meta a')
+ .text(),
+ };
+ return info;
+ })
+ .get();
+
+ ctx.state.data = {
+ title: 'psnine-' + $('title').text(),
+ link: 'https://www.psnine.com/',
+ item: out,
+ };
+};
diff --git a/lib/routes/psnine/news.js b/lib/routes/psnine/news.js
new file mode 100644
index 000000000..43061f3f4
--- /dev/null
+++ b/lib/routes/psnine/news.js
@@ -0,0 +1,42 @@
+const axios = require('../../utils/axios');
+const cheerio = require('cheerio');
+const date = require('../../utils/date');
+
+module.exports = async (ctx) => {
+ const url = 'https://www.psnine.com/news';
+ const response = await axios({
+ method: 'get',
+ url: url,
+ });
+
+ const data = response.data;
+ const $ = cheerio.load(data);
+
+ const out = $('.box li')
+ .map(function() {
+ const info = {
+ title: $(this)
+ .find('.content')
+ .text(),
+ link: $(this)
+ .find('.touch')
+ .attr('href'),
+ pubDate: date(
+ $(this)
+ .find('.meta')
+ .text()
+ ),
+ author: $(this)
+ .find('.meta a')
+ .text(),
+ };
+ return info;
+ })
+ .get();
+
+ ctx.state.data = {
+ title: 'psnine-' + $('title').text(),
+ link: 'https://www.psnine.com/',
+ item: out,
+ };
+};
diff --git a/lib/routes/psnine/shuzhe.js b/lib/routes/psnine/shuzhe.js
new file mode 100644
index 000000000..a59b68cdd
--- /dev/null
+++ b/lib/routes/psnine/shuzhe.js
@@ -0,0 +1,45 @@
+const axios = require('../../utils/axios');
+const cheerio = require('cheerio');
+const date = require('../../utils/date');
+
+module.exports = async (ctx) => {
+ const url = 'https://www.psnine.com/dd';
+ const response = await axios({
+ method: 'get',
+ url: url,
+ });
+
+ const data = response.data;
+ const $ = cheerio.load(data);
+
+ const out = $('.dd_ul li')
+ .map(function() {
+ const info = {
+ title: $(this)
+ .find('.dd_title')
+ .text(),
+ link: $(this)
+ .find('.dd_title a')
+ .attr('href'),
+ description: $(this)
+ .find('.dd_status')
+ .text(),
+ pubDate: date(
+ $(this)
+ .find('.meta')
+ .text()
+ ),
+ author: $(this)
+ .find('.meta a')
+ .text(),
+ };
+ return info;
+ })
+ .get();
+
+ ctx.state.data = {
+ title: 'psnine-' + $('title').text(),
+ link: 'https://www.psnine.com/',
+ item: out,
+ };
+};
diff --git a/lib/routes/psnine/trade.js b/lib/routes/psnine/trade.js
new file mode 100644
index 000000000..2361c686f
--- /dev/null
+++ b/lib/routes/psnine/trade.js
@@ -0,0 +1,49 @@
+const axios = require('../../utils/axios');
+const cheerio = require('cheerio');
+const date = require('../../utils/date');
+
+module.exports = async (ctx) => {
+ const url = 'https://www.psnine.com/trade';
+ const response = await axios({
+ method: 'get',
+ url: url,
+ });
+
+ const data = response.data;
+ const $ = cheerio.load(data);
+
+ const out = $('.list li')
+ .map(function() {
+ const desc = [];
+ $(this)
+ .find('.meta a')
+ .each(function(i) {
+ desc[i] = $(this).text();
+ });
+ const info = {
+ title: $(this)
+ .find('.content')
+ .text(),
+ link: $(this)
+ .find('.touch')
+ .attr('href'),
+ description: desc.join(' '),
+ pubDate: date(
+ $(this)
+ .find('.meta')
+ .text()
+ ),
+ author: $(this)
+ .find('.psnnode')
+ .text(),
+ };
+ return info;
+ })
+ .get();
+
+ ctx.state.data = {
+ title: 'psnine-' + $('title').text(),
+ link: 'https://www.psnine.com/',
+ item: out,
+ };
+};
diff --git a/lib/routes/yystv/category.js b/lib/routes/yystv/category.js
new file mode 100644
index 000000000..4533589a6
--- /dev/null
+++ b/lib/routes/yystv/category.js
@@ -0,0 +1,71 @@
+const axios = require('../../utils/axios');
+const cheerio = require('cheerio');
+const date = require('../../utils/date');
+
+module.exports = async (ctx) => {
+ const category = ctx.params.category;
+ const url = `http://www.yystv.cn/b/${category}`;
+ const response = await axios({
+ method: 'get',
+ url: url,
+ });
+
+ 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, 18)
+ .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: '游研社-' + $('title').text(),
+ link: 'http://www.yystv.cn/b/recommend',
+ item: first_part.concat(second_part),
+ };
+};