parent
c4c80d88de
commit
def00b1f8d
|
|
@ -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="首页推荐" author="LogicJake" example="/gushiwen/recommend" path="/gushiwen/recommend"/>
|
||||
|
||||
### 电商在线
|
||||
|
||||
<Route name="电商在线" author="LogicJake" example="/imaijia/category/xls" path="/imaijia/category/:category" :paramsDesc="['类别id,可在 URL 中找到']" />
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue