add: duozhi.com (#1526)
This commit is contained in:
parent
44189d5261
commit
521f126ba6
|
|
@ -2917,6 +2917,10 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看
|
|||
|
||||
<route name="新闻" author="howel.52" example="/jpmorganchase" path="/jpmorganchase"/>
|
||||
|
||||
### 多知网
|
||||
|
||||
<route name="首页" author="WenryXu" example="/duozhi" path="/duozhi"/>
|
||||
|
||||
### 人人都是产品经理
|
||||
|
||||
<route name="用户收藏" author="LogicJake" example="/woshipm/bookmarks/324696" path="/woshipm/bookmarks/:id" :paramsDesc="['用户id']"/>
|
||||
|
|
|
|||
|
|
@ -1024,6 +1024,9 @@ router.get('/jpmorganchase', require('./routes/jpmorganchase/research'));
|
|||
// 美拍
|
||||
router.get('/meipai/user/:uid', require('./routes/meipai/user'));
|
||||
|
||||
// 多知网
|
||||
router.get('/duozhi', require('./routes/duozhi'));
|
||||
|
||||
// Docker Hub
|
||||
router.get('/dockerhub/build/:owner/:image/:tag?', require('./routes/dockerhub/build'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await axios('http://www.duozhi.com/');
|
||||
const $ = cheerio.load(response.data);
|
||||
const postList = $('.post-list .post').get();
|
||||
const result = await Promise.all(
|
||||
postList.map(async (item) => {
|
||||
const title = $(item)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.text();
|
||||
const link = $(item)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href');
|
||||
const guid = $(item)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href');
|
||||
const temp = await axios(link);
|
||||
const description = $(temp.data)
|
||||
.find('.subject-content')
|
||||
.html()
|
||||
.replace(/alt="\\"/g, '');
|
||||
const pubDate = new Date(
|
||||
$(temp.data)
|
||||
.find('.meta-date')
|
||||
.text()
|
||||
.substr(0, 18)
|
||||
).toUTCString();
|
||||
const single = {
|
||||
title: title,
|
||||
link: link,
|
||||
guid: guid,
|
||||
pubDate: pubDate,
|
||||
description: description,
|
||||
};
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
ctx.state.data = { title: '多知网', link: 'http://www.duozhi.com/', description: '独立商业视角 新锐教育观察', item: result };
|
||||
};
|
||||
Loading…
Reference in New Issue