mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-07 21:47:57 +08:00
add 我是产品经理用户收藏 (#1533)
This commit is contained in:
@@ -2893,4 +2893,5 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看
|
||||
|
||||
### 人人都是产品经理
|
||||
|
||||
<route name="用户收藏" author="LogicJake" example="/woshipm/bookmarks/324696" path="/woshipm/bookmarks/:id" :paramsDesc="['用户id']"/>
|
||||
<route name="用户文章" author="LogicJake" example="/woshipm/user_article/324696" path="/woshipm/user_article/:id" :paramsDesc="['用户id']"/>
|
||||
|
||||
@@ -1021,6 +1021,7 @@ router.get('/jpmorganchase', require('./routes/jpmorganchase/research'));
|
||||
router.get('/meipai/user/:uid', require('./routes/meipai/user'));
|
||||
|
||||
// 人人都是产品经理
|
||||
router.get('/woshipm/bookmarks/:id', require('./routes/woshipm/bookmarks'));
|
||||
router.get('/woshipm/user_article/:id', require('./routes/woshipm/user_article'));
|
||||
|
||||
// 高清电台
|
||||
|
||||
47
lib/routes/woshipm/bookmarks.js
Normal file
47
lib/routes/woshipm/bookmarks.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const link = `http://www.woshipm.com/u/${id}`;
|
||||
const response = await axios.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const name = $('div.name').text();
|
||||
|
||||
const remark_api = `http://www.woshipm.com/__api/v1/users/${id}/bookmarks`;
|
||||
const response_api = await axios.get(remark_api);
|
||||
const list = response_api.data.payload.value;
|
||||
const out = await Promise.all(
|
||||
list.map(async (info) => {
|
||||
const title = info.title;
|
||||
const date = info.date;
|
||||
const itemUrl = info.permalink;
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await axios.get(itemUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const description = $('div.grap')
|
||||
.html()
|
||||
.trim();
|
||||
|
||||
const single = {
|
||||
title: title,
|
||||
link: itemUrl,
|
||||
description: description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name}的收藏-人人都是产品经理`,
|
||||
link: link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user