mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: 新增人人都是产品经理 - 天天问 (#3596)
This commit is contained in:
@@ -618,6 +618,10 @@ pageClass: routes
|
||||
|
||||
<Route author="WenryXu" example="/woshipm/popular" path="/woshipm/popular"/>
|
||||
|
||||
### 天天问
|
||||
|
||||
<Route author="WenryXu" example="/woshipm/wen" path="/woshipm/wen"/>
|
||||
|
||||
### 用户收藏
|
||||
|
||||
<Route author="LogicJake" example="/woshipm/bookmarks/324696" path="/woshipm/bookmarks/:id" :paramsDesc="['用户 id']"/>
|
||||
|
||||
@@ -1133,6 +1133,7 @@ router.get('/dockerhub/build/:owner/:image/:tag?', require('./routes/dockerhub/b
|
||||
|
||||
// 人人都是产品经理
|
||||
router.get('/woshipm/popular', require('./routes/woshipm/popular'));
|
||||
router.get('/woshipm/wen', require('./routes/woshipm/wen'));
|
||||
router.get('/woshipm/bookmarks/:id', require('./routes/woshipm/bookmarks'));
|
||||
router.get('/woshipm/user_article/:id', require('./routes/woshipm/user_article'));
|
||||
|
||||
|
||||
45
lib/routes/woshipm/wen.js
Normal file
45
lib/routes/woshipm/wen.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got('https://wen.woshipm.com/m/main/indexNewData.html');
|
||||
const $ = cheerio.load(response.data);
|
||||
const postList = $('.article-list-item').get();
|
||||
const result = await Promise.all(
|
||||
postList.map(async (item) => {
|
||||
const title = $(item)
|
||||
.find('.went-head-text')
|
||||
.text();
|
||||
const link =
|
||||
'https://wen.woshipm.com/' +
|
||||
$(item)
|
||||
.find('.went-head')
|
||||
.attr('href');
|
||||
const pubDate = new Date().toUTCString();
|
||||
|
||||
const single = {
|
||||
title: title,
|
||||
link: link,
|
||||
guid: link,
|
||||
pubDate: pubDate,
|
||||
description: '',
|
||||
};
|
||||
|
||||
const key = link;
|
||||
const value = await ctx.cache.get(key);
|
||||
|
||||
if (value) {
|
||||
single.description = value;
|
||||
} else {
|
||||
const temp = await got(link);
|
||||
const $ = cheerio.load(temp.data);
|
||||
single.description = $('.wt-desc').html();
|
||||
|
||||
ctx.cache.set(key, single.description);
|
||||
}
|
||||
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
ctx.state.data = { title: '天天问 - 人人都是产品经理', link: 'http://wen.woshipm.com/', item: result };
|
||||
};
|
||||
Reference in New Issue
Block a user