let express = require('express'); let request = require('request'); let common = require('../common/common.json'); // 引用公共文件 let router = express.Router();
/** 获取小说源 返回盗版源和正版源 param id {String} 是首页和搜索返回接口 books[i].id param n {Number || String} 使用第几个源,可以不用传参默认 1 http://api.zhuishushenqi.com/atoc?view=summary&book=${bookID} */ router.get('/', function (req, res, next) { if (!req.query.id) { res.send(JSON.stringify({ "flag": 0, "msg": "请传入ID..." })); } // req.query.id 编码转义 let id = encodeURI(req.query.id); request.get(`${common.API}/atoc?view=summary&book=${id}`, function (err, response, body){ if(err){ res.send(JSON.stringify({ "flag": 0, "msg": "请求出错了..." })); } // 解析返回的数据 body = JSON.parse(body); // 判断是否返回内容 if (body.length == 0){ res.send(JSON.stringify({ "flag": 0, "msg": "没有获取到小说源,换个小说看吧" })); }
// 第一个源是正版源,是收费加密的,所以默认选中第二个源 let n = parseInt(req.query.n); if (isNaN(n) || n == 0){ n = 1; }
let express = require('express'); let request = require('request'); let common = require('../common/common.json'); // 引用公共文件 let router = express.Router();
/** 获取小说文章列表 返回小说文章列表 param id {String} 是小说源接口 books.id http://api.zhuishushenqi.com/atoc/${id}?view=chapters */ router.get('/', function (req, res, next) { if (!req.query.id){ res.send(JSON.stringify({ "flag": 0, "msg": "请传入ID..." })); } // req.query.id 编码转义 let id = encodeURIComponent(req.query.id); request.get(`${common.API}/atoc/${id}?view=chapters`, function (err, response, body) { if (err) { res.send(JSON.stringify({ "flag": 0, "msg": "请求出错了..." })); }
let express = require('express'); let request = require('request'); let common = require('../common/common.json'); // 引用公共文件 let router = express.Router();
/** 获取小说文章内容 返回小说文章内容 param link {String} 是小说文章列表接口 chapters[0].link http://chapter2.zhuishushenqi.com/chapter/${link} */ router.get('/', function (req, res, next) { if (!req.query.link) { res.send(JSON.stringify({ "flag": 0, "msg": "请传入link..." })); } // req.query.link 编码转义 let link = encodeURIComponent(req.query.link); request.get(`${common.CHAPTER}/chapter/${link}`, function (err, response, body) { if (err) { res.send(JSON.stringify({ "flag": 0, "msg": "请求出错了..." })); }
let express = require('express'); let request = require('request'); let common = require('../common/common.json'); // 引用公共文件 let router = express.Router();
/** 获取排行榜 返回排行榜 param id {String} 没有传参数就是获取全部榜单,否则根据参数获取榜单 http://api.zhuishushenqi.com/ranking/gender http://api.zhuishushenqi.com/ranking/${id} */
router.get('/', function (req, res, next) { // 获取全部榜单 request.get(`${common.API}/ranking/gender`, function (err, response, body) { if (err) { res.send(JSON.stringify({ "flag": 0, "msg": "请求出错了..." })); }