mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
@@ -606,6 +606,17 @@ pageClass: routes
|
|||||||
|
|
||||||
<Route author="ihewro" example="/meipai/user/56537299" path="/meipai/user/:id" :paramsDesc="['用户 id, 可在 分享出去获得的用户主页 URL 中找到']"/>
|
<Route author="ihewro" example="/meipai/user/56537299" path="/meipai/user/:id" :paramsDesc="['用户 id, 可在 分享出去获得的用户主页 URL 中找到']"/>
|
||||||
|
|
||||||
|
## 搜狐
|
||||||
|
|
||||||
|
### 搜狐号
|
||||||
|
|
||||||
|
<Route author="HenryQW" example="/sohu/mp/119097" path="/sohu/mp/:id" :paramsDesc="['搜狐号 ID', '见如下说明']">
|
||||||
|
|
||||||
|
1. 通过浏览器搜索相关搜狐号 `果壳 site: mp.sohu.com`。
|
||||||
|
1. 通过浏览器控制台执行 `cfgs.author_id`,返回的即为搜狐号 ID。
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 贴吧
|
## 贴吧
|
||||||
|
|
||||||
### 帖子列表
|
### 帖子列表
|
||||||
|
|||||||
@@ -1669,4 +1669,7 @@ router.get('/nciae/xsxx', require('./routes/universities/nciae/xsxx'));
|
|||||||
// cfan
|
// cfan
|
||||||
router.get('/cfan/news', require('./routes/cfan/news'));
|
router.get('/cfan/news', require('./routes/cfan/news'));
|
||||||
|
|
||||||
|
// 搜狐 - 搜狐号
|
||||||
|
router.get('/sohu/mp/:id', require('./routes/sohu/mp'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
48
lib/routes/sohu/mp.js
Normal file
48
lib/routes/sohu/mp.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const date = require('@/utils/date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const { id } = ctx.params;
|
||||||
|
|
||||||
|
const response = await got.get(`https://v2.sohu.com/author-page-api/author-articles/pc/${id}`);
|
||||||
|
|
||||||
|
const list = response.data.data.pcArticleVOS.splice(0, 10);
|
||||||
|
let author, link;
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
list.map(async (e) => {
|
||||||
|
const response = await ctx.cache.tryGet(e.link, async () => (await got.get(e.link)).data);
|
||||||
|
const $ = cheerio.load(response);
|
||||||
|
|
||||||
|
if (!author) {
|
||||||
|
const meta = $('#article-container h4 > a');
|
||||||
|
author = meta.text();
|
||||||
|
link = meta.attr('href').split('==')[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
const article = $('#mp-editor');
|
||||||
|
|
||||||
|
article.find('#backsohucom, p[data-role="editor-name"]').each((i, e) => {
|
||||||
|
$(e).remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title: e.title,
|
||||||
|
link: e.link,
|
||||||
|
description: article.html(),
|
||||||
|
pubDate: date(e.publicTimeStr, 8),
|
||||||
|
author,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `搜狐号 - ${author}`,
|
||||||
|
link,
|
||||||
|
description: '',
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user