fix(route): woshipm (#11669)
* fix(route): woshipm * fix: remove used id
This commit is contained in:
+11
-5
@@ -3385,23 +3385,29 @@ column 为 third 时可选的 category:
|
||||
|
||||
### 热门文章
|
||||
|
||||
<Route author="WenryXu" example="/woshipm/popular" path="/woshipm/popular"/>
|
||||
<Route author="WenryXu" example="/woshipm/popular" path="/woshipm/popular/:range?" :paramsDesc="['时间,见下表,默认为 `daily`']" radar="1">
|
||||
|
||||
| 日榜 | 周榜 | 月榜 |
|
||||
| ----- | ------ | ------- |
|
||||
| daily | weekly | monthly |
|
||||
|
||||
</Route>
|
||||
|
||||
### 天天问
|
||||
|
||||
<Route author="WenryXu" example="/woshipm/wen" path="/woshipm/wen"/>
|
||||
<Route author="WenryXu" example="/woshipm/wen" path="/woshipm/wen" radar="1"/>
|
||||
|
||||
### 用户收藏
|
||||
|
||||
<Route author="LogicJake" example="/woshipm/bookmarks/324696" path="/woshipm/bookmarks/:id" :paramsDesc="['用户 id']"/>
|
||||
<Route author="LogicJake" example="/woshipm/bookmarks/324696" path="/woshipm/bookmarks/:id" :paramsDesc="['用户 id']" radar="1"/>
|
||||
|
||||
### 用户文章
|
||||
|
||||
<Route author="LogicJake" example="/woshipm/user_article/324696" path="/woshipm/user_article/:id" :paramsDesc="['用户 id']"/>
|
||||
<Route author="LogicJake" example="/woshipm/user_article/324696" path="/woshipm/user_article/:id" :paramsDesc="['用户 id']" radar="1"/>
|
||||
|
||||
### 最新文章
|
||||
|
||||
<Route author="Director-0428" example="/woshipm/latest" path="/woshipm/latest"/>
|
||||
<Route author="Director-0428" example="/woshipm/latest" path="/woshipm/latest" radar="1"/>
|
||||
|
||||
## 人人都是自媒体
|
||||
|
||||
|
||||
+5
-5
@@ -1286,11 +1286,11 @@ router.get('/meipai/user/:uid', lazyloadRouteHandler('./routes/meipai/user'));
|
||||
router.get('/duozhi', lazyloadRouteHandler('./routes/duozhi'));
|
||||
|
||||
// 人人都是产品经理
|
||||
router.get('/woshipm/popular', lazyloadRouteHandler('./routes/woshipm/popular'));
|
||||
router.get('/woshipm/wen', lazyloadRouteHandler('./routes/woshipm/wen'));
|
||||
router.get('/woshipm/bookmarks/:id', lazyloadRouteHandler('./routes/woshipm/bookmarks'));
|
||||
router.get('/woshipm/user_article/:id', lazyloadRouteHandler('./routes/woshipm/user_article'));
|
||||
router.get('/woshipm/latest', lazyloadRouteHandler('./routes/woshipm/latest'));
|
||||
// router.get('/woshipm/popular', lazyloadRouteHandler('./routes/woshipm/popular'));
|
||||
// router.get('/woshipm/wen', lazyloadRouteHandler('./routes/woshipm/wen'));
|
||||
// router.get('/woshipm/bookmarks/:id', lazyloadRouteHandler('./routes/woshipm/bookmarks'));
|
||||
// router.get('/woshipm/user_article/:id', lazyloadRouteHandler('./routes/woshipm/user_article'));
|
||||
// router.get('/woshipm/latest', lazyloadRouteHandler('./routes/woshipm/latest'));
|
||||
|
||||
// 高清电台
|
||||
router.get('/gaoqing/latest', lazyloadRouteHandler('./routes/gaoqing/latest'));
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const link = `http://www.woshipm.com/u/${id}`;
|
||||
const response = await got.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 got.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 got.get(itemUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const description = $('div.grap').html().trim();
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
description,
|
||||
pubDate: new Date(date).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name}的收藏-人人都是产品经理`,
|
||||
link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
@@ -1,45 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response_1 = await got('http://www.woshipm.com/__api/v1/stream-list');
|
||||
const response_2 = await got('http://www.woshipm.com/__api/v1/stream-list/page/2');
|
||||
const response_3 = await got('http://www.woshipm.com/__api/v1/stream-list/page/3');
|
||||
const payload = [...response_1.data.payload, ...response_2.data.payload, ...response_3.data.payload];
|
||||
const result = await Promise.all(
|
||||
payload.map(async (item) => {
|
||||
const title = item.title;
|
||||
const link = item.permalink;
|
||||
const guid = item.id;
|
||||
const pubDate = new Date(item.date).toUTCString();
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link,
|
||||
guid,
|
||||
pubDate,
|
||||
description: '',
|
||||
};
|
||||
|
||||
const key = 'woshipm' + guid;
|
||||
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 = $('.grap').html();
|
||||
|
||||
ctx.cache.set(key, single.description);
|
||||
}
|
||||
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: '最新文章 - 人人都是产品经理',
|
||||
link: 'http://www.woshipm.com/',
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
@@ -1,38 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got('http://www.woshipm.com/__api/v1/browser/popular');
|
||||
const result = await Promise.all(
|
||||
response.data.payload.map(async (item) => {
|
||||
const title = item.title;
|
||||
const link = item.permalink;
|
||||
const guid = item.id;
|
||||
const pubDate = new Date(item.date).toUTCString();
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link,
|
||||
guid,
|
||||
pubDate,
|
||||
description: '',
|
||||
};
|
||||
|
||||
const key = 'woshipm' + guid;
|
||||
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 = $('.grap').html();
|
||||
|
||||
ctx.cache.set(key, single.description);
|
||||
}
|
||||
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
ctx.state.data = { title: '热门文章 - 人人都是产品经理', link: 'http://www.woshipm.com/', item: result };
|
||||
};
|
||||
@@ -1,39 +0,0 @@
|
||||
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,
|
||||
link,
|
||||
guid: link,
|
||||
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 };
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { baseUrl, parseArticle } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const { data: profile } = await got(`${baseUrl}/api2/user/profile`, {
|
||||
searchParams: {
|
||||
uid: id,
|
||||
},
|
||||
});
|
||||
const userInfo = profile.RESULT.userInfoVo;
|
||||
const name = userInfo.nickName;
|
||||
|
||||
const remark_api = `${baseUrl}/__api/v1/users/${id}/bookmarks`;
|
||||
const response_api = await got(remark_api);
|
||||
const list = response_api.data.payload.value.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.snipper,
|
||||
link: item.permalink,
|
||||
pubDate: parseDate(item.date, 'YYYY/MM/DD'),
|
||||
author: item.author.name,
|
||||
}));
|
||||
|
||||
const out = await Promise.all(list.map((info) => parseArticle(info, ctx.cache.tryGet)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name}的收藏-人人都是产品经理`,
|
||||
description: userInfo.description,
|
||||
image: userInfo.avartar,
|
||||
link: `${baseUrl}/u/${id}`,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { baseUrl, parseArticle } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const pages = 3;
|
||||
const urlList = Array.from({ length: pages }, (_, v) => `${baseUrl}/__api/v1/stream-list${v < 1 ? '' : `/page/${v + 1}`}`);
|
||||
const responses = await got.all(urlList.map((url) => got(url)));
|
||||
|
||||
const payload = responses.map((response) => response.data.payload).flat();
|
||||
|
||||
const list = payload.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.snipper,
|
||||
link: item.permalink,
|
||||
pubDate: parseDate(item.date, 'YYYY/MM/DD'),
|
||||
author: item.author.name,
|
||||
}));
|
||||
|
||||
const result = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: '最新文章 - 人人都是产品经理',
|
||||
link: baseUrl,
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
'/bookmarks/:id': ['LogicJake'],
|
||||
'/latest': ['Director-0428'],
|
||||
'/popular/:range?': ['WenryXu'],
|
||||
'/user_article/:id': ['LogicJake'],
|
||||
'/wen': ['WenryXu'],
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { baseUrl, parseArticle } = require('./utils');
|
||||
|
||||
const rangeMap = {
|
||||
daily: '日榜',
|
||||
weekly: '周榜',
|
||||
monthly: '月榜',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { range = 'daily' } = ctx.params;
|
||||
const { data: response } = await got(`${baseUrl}/api2/app/article/popular/${range}`);
|
||||
|
||||
const list = response.RESULT.map((item) => {
|
||||
item = item.data;
|
||||
return {
|
||||
title: item.articleTitle,
|
||||
description: item.articleSummary,
|
||||
link: `${baseUrl}/${item.type}/${item.id}.html`,
|
||||
pubDate: parseDate(item.publishTime, 'x'),
|
||||
author: item.articleAuthor,
|
||||
};
|
||||
});
|
||||
|
||||
const result = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `热门文章 - ${rangeMap[range]} - 人人都是产品经理`,
|
||||
link: baseUrl,
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
module.exports = {
|
||||
'woshipm.com': {
|
||||
_name: '人人都是产品经理',
|
||||
'.': [
|
||||
{
|
||||
title: '热门文章',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#ren-ren-dui-shi-chan-pin-jing-li',
|
||||
source: ['/'],
|
||||
target: '/woshipm/popular',
|
||||
},
|
||||
{
|
||||
title: '用户收藏',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#ren-ren-dui-shi-chan-pin-jing-li',
|
||||
source: ['/u/:id'],
|
||||
target: '/woshipm/bookmarks/:id',
|
||||
},
|
||||
{
|
||||
title: '用户文章',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#ren-ren-dui-shi-chan-pin-jing-li',
|
||||
source: ['/u/:id'],
|
||||
target: '/woshipm/user_article/:id',
|
||||
},
|
||||
{
|
||||
title: '最新文章',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#ren-ren-dui-shi-chan-pin-jing-li',
|
||||
source: ['/'],
|
||||
target: '/woshipm/latest',
|
||||
},
|
||||
],
|
||||
wen: [
|
||||
{
|
||||
title: '天天问',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#ren-ren-dui-shi-chan-pin-jing-li',
|
||||
source: ['/'],
|
||||
target: '/woshipm/wen',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/bookmarks/:id', require('./bookmarks'));
|
||||
router.get('/latest', require('./latest'));
|
||||
router.get('/popular/:range?', require('./popular'));
|
||||
router.get('/user_article/:id', require('./user_article'));
|
||||
router.get('/wen', require('./wen'));
|
||||
};
|
||||
@@ -1,11 +1,12 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { baseUrl, parseArticle } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const limit = ctx.query.limit || 10;
|
||||
const link = `http://www.woshipm.com/u/${id}`;
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 12;
|
||||
const link = `${baseUrl}/u/${id}`;
|
||||
|
||||
const data = await got(link).then((res) => res.data);
|
||||
const $ = cheerio.load(data);
|
||||
@@ -13,7 +14,8 @@ module.exports = async (ctx) => {
|
||||
|
||||
const list = $('.post--card')
|
||||
.slice(0, limit)
|
||||
.map((_, item) => {
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const postCardTitle = item.find('h2.post--card__title a');
|
||||
return {
|
||||
@@ -21,22 +23,14 @@ module.exports = async (ctx) => {
|
||||
link: postCardTitle.attr('href'),
|
||||
pubDate: parseDate(item.find('time').text(), 'YYYY-MM-DD'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const data = await got(item.link).then((res) => res.data);
|
||||
const content = cheerio.load(data);
|
||||
item.description = content('div.grap').html().trim();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name}的文章-人人都是产品经理`,
|
||||
description: $('.author--meta .description').text(),
|
||||
image: $('.author--meta .avatar').attr('src').split('!')[0],
|
||||
link,
|
||||
item: items,
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const baseUrl = 'https://www.woshipm.com';
|
||||
|
||||
const parseArticle = (item, tryGet) =>
|
||||
tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
$('.support-author').remove();
|
||||
|
||||
item.description = $('.article--content').html();
|
||||
|
||||
return item;
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
baseUrl,
|
||||
parseArticle,
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const baseUrl = 'https://wen.woshipm.com';
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got(`${baseUrl}/m/main/indexNewData.html`);
|
||||
const $ = cheerio.load(response.data);
|
||||
const postList = $('.article-list-item')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('.went-head-text').text(),
|
||||
link: `${baseUrl}${item.find('.went-head').attr('href')}`,
|
||||
pubDate: parseRelativeDate(item.find('.list-text').text().split('|')[1]),
|
||||
};
|
||||
});
|
||||
|
||||
const result = await Promise.all(
|
||||
postList.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const temp = await got(item.link);
|
||||
const $ = cheerio.load(temp.data);
|
||||
item.description = $('.wt-desc').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '天天问 - 人人都是产品经理',
|
||||
link: baseUrl,
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user