diff --git a/docs/other.md b/docs/other.md index a55555cd27..f4cdc5f938 100644 --- a/docs/other.md +++ b/docs/other.md @@ -486,6 +486,10 @@ type 为 all 时,category 参数不支持 cost 和 free +### 古诗文网 + + + ### 电商在线 diff --git a/lib/router.js b/lib/router.js index d5386d6f89..b3e8e2d898 100755 --- a/lib/router.js +++ b/lib/router.js @@ -1255,6 +1255,9 @@ router.get('/mobdata/report', require('./routes/mobdata/report')); // 谷雨 router.get('/tencent/guyu/channel/:name', require('./routes/tencent/guyu/channel')); +// 古诗文网 +router.get('/gushiwen/recommend', require('./routes/gushiwen/recommend')); + // 电商在线 router.get('/imaijia/category/:category', require('./routes/imaijia/category')); diff --git a/lib/routes/gushiwen/recommend.js b/lib/routes/gushiwen/recommend.js new file mode 100644 index 0000000000..3244d6973b --- /dev/null +++ b/lib/routes/gushiwen/recommend.js @@ -0,0 +1,41 @@ +const cheerio = require('cheerio'); +const axios = require('../../utils/axios'); + +module.exports = async (ctx) => { + const url = 'https://www.gushiwen.org/'; + const res = await axios.get(url); + const $ = cheerio.load(res.data); + + const list = $('div.sons'); + const out = list + .slice(0, 10) + .map(function() { + const title = $(this) + .find('b') + .text(); + const link = $(this) + .find('p a') + .attr('href'); + const description = $(this) + .find('div.contson') + .html(); + const author = $(this) + .find('p.source') + .text(); + const item = { + title, + link, + description, + author, + }; + + return item; + }) + .get(); + + ctx.state.data = { + title: '古诗文推荐', + link: url, + item: out, + }; +};