diff --git a/docs/new-media.md b/docs/new-media.md
index 21571c2cb..835029e16 100644
--- a/docs/new-media.md
+++ b/docs/new-media.md
@@ -3385,23 +3385,29 @@ column 为 third 时可选的 category:
### 热门文章
-
+
+
+| 日榜 | 周榜 | 月榜 |
+| ----- | ------ | ------- |
+| daily | weekly | monthly |
+
+
### 天天问
-
+
### 用户收藏
-
+
### 用户文章
-
+
### 最新文章
-
+
## 人人都是自媒体
diff --git a/lib/router.js b/lib/router.js
index 66165ba01..bfc2adcf1 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -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'));
diff --git a/lib/routes/woshipm/bookmarks.js b/lib/routes/woshipm/bookmarks.js
deleted file mode 100644
index 0b9d278fa..000000000
--- a/lib/routes/woshipm/bookmarks.js
+++ /dev/null
@@ -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,
- };
-};
diff --git a/lib/routes/woshipm/latest.js b/lib/routes/woshipm/latest.js
deleted file mode 100644
index cf71e27e4..000000000
--- a/lib/routes/woshipm/latest.js
+++ /dev/null
@@ -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,
- };
-};
diff --git a/lib/routes/woshipm/popular.js b/lib/routes/woshipm/popular.js
deleted file mode 100644
index f0b6c25ed..000000000
--- a/lib/routes/woshipm/popular.js
+++ /dev/null
@@ -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 };
-};
diff --git a/lib/routes/woshipm/wen.js b/lib/routes/woshipm/wen.js
deleted file mode 100644
index 2bb5495d8..000000000
--- a/lib/routes/woshipm/wen.js
+++ /dev/null
@@ -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 };
-};
diff --git a/lib/v2/woshipm/bookmarks.js b/lib/v2/woshipm/bookmarks.js
new file mode 100644
index 000000000..48db20542
--- /dev/null
+++ b/lib/v2/woshipm/bookmarks.js
@@ -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,
+ };
+};
diff --git a/lib/v2/woshipm/latest.js b/lib/v2/woshipm/latest.js
new file mode 100644
index 000000000..56b45ef05
--- /dev/null
+++ b/lib/v2/woshipm/latest.js
@@ -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,
+ };
+};
diff --git a/lib/v2/woshipm/maintainer.js b/lib/v2/woshipm/maintainer.js
new file mode 100644
index 000000000..7e8967faf
--- /dev/null
+++ b/lib/v2/woshipm/maintainer.js
@@ -0,0 +1,7 @@
+module.exports = {
+ '/bookmarks/:id': ['LogicJake'],
+ '/latest': ['Director-0428'],
+ '/popular/:range?': ['WenryXu'],
+ '/user_article/:id': ['LogicJake'],
+ '/wen': ['WenryXu'],
+};
diff --git a/lib/v2/woshipm/popular.js b/lib/v2/woshipm/popular.js
new file mode 100644
index 000000000..229acdc33
--- /dev/null
+++ b/lib/v2/woshipm/popular.js
@@ -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,
+ };
+};
diff --git a/lib/v2/woshipm/radar.js b/lib/v2/woshipm/radar.js
new file mode 100644
index 000000000..54c5aeb72
--- /dev/null
+++ b/lib/v2/woshipm/radar.js
@@ -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',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/woshipm/router.js b/lib/v2/woshipm/router.js
new file mode 100644
index 000000000..a82ffd18b
--- /dev/null
+++ b/lib/v2/woshipm/router.js
@@ -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'));
+};
diff --git a/lib/routes/woshipm/user_article.js b/lib/v2/woshipm/user_article.js
similarity index 61%
rename from lib/routes/woshipm/user_article.js
rename to lib/v2/woshipm/user_article.js
index 0615796ce..44d62f8e2 100644
--- a/lib/routes/woshipm/user_article.js
+++ b/lib/v2/woshipm/user_article.js
@@ -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,
};
diff --git a/lib/v2/woshipm/utils.js b/lib/v2/woshipm/utils.js
new file mode 100644
index 000000000..491c67885
--- /dev/null
+++ b/lib/v2/woshipm/utils.js
@@ -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,
+};
diff --git a/lib/v2/woshipm/wen.js b/lib/v2/woshipm/wen.js
new file mode 100644
index 000000000..0b1347f51
--- /dev/null
+++ b/lib/v2/woshipm/wen.js
@@ -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,
+ };
+};