add 古诗文网 (#1975)

* update bug report template

* add 古诗文网
This commit is contained in:
Chenyang Shi
2019-04-24 15:59:07 +08:00
committed by DIYgod
parent c4c80d88de
commit def00b1f8d
3 changed files with 48 additions and 0 deletions

View File

@@ -486,6 +486,10 @@ type 为 all 时category 参数不支持 cost 和 free
<Route name="美国签证 check 动态" author="lalxyy" example="/checkee/2019-03" path="/checkee/:month" :paramsDesc="['签证被 check 的年份-月份,如 2019-03']" /> <Route name="美国签证 check 动态" author="lalxyy" example="/checkee/2019-03" path="/checkee/:month" :paramsDesc="['签证被 check 的年份-月份,如 2019-03']" />
### 古诗文网
<Route name="首页推荐" author="LogicJake" example="/gushiwen/recommend" path="/gushiwen/recommend"/>
### 电商在线 ### 电商在线
<Route name="电商在线" author="LogicJake" example="/imaijia/category/xls" path="/imaijia/category/:category" :paramsDesc="['类别id可在 URL 中找到']" /> <Route name="电商在线" author="LogicJake" example="/imaijia/category/xls" path="/imaijia/category/:category" :paramsDesc="['类别id可在 URL 中找到']" />

View File

@@ -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('/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')); router.get('/imaijia/category/:category', require('./routes/imaijia/category'));

View File

@@ -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,
};
};