mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: 添加woshipm的最新文章 (#4281)
This commit is contained in:
@@ -719,6 +719,10 @@ Supported sub-sites:
|
||||
|
||||
<Route author="LogicJake" example="/woshipm/user_article/324696" path="/woshipm/user_article/:id" :paramsDesc="['用户 id']"/>
|
||||
|
||||
### 最新文章
|
||||
|
||||
<Route author="Director-0428" example="/woshipm/latest" path="/woshipm/latest"/>
|
||||
|
||||
## 少数派 sspai
|
||||
|
||||
### 最新上架付费专栏
|
||||
|
||||
@@ -1208,6 +1208,7 @@ 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'));
|
||||
router.get('/woshipm/latest', require('./routes/woshipm/latest'));
|
||||
|
||||
// 高清电台
|
||||
router.get('/gaoqing/latest', require('./routes/gaoqing/latest'));
|
||||
|
||||
45
lib/routes/woshipm/latest.js
Normal file
45
lib/routes/woshipm/latest.js
Normal file
@@ -0,0 +1,45 @@
|
||||
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: title,
|
||||
link: link,
|
||||
guid: guid,
|
||||
pubDate: 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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user