feat: add 企鹅号 (#2959)

This commit is contained in:
Chenyang Shi
2019-08-30 00:10:41 +08:00
committed by DIYgod
parent a73d0418bf
commit d218976538
3 changed files with 48 additions and 0 deletions
+6
View File
@@ -617,6 +617,12 @@ pageClass: routes
</Route>
## 腾讯
### 企鹅号
<Route author="LogicJake" example="/tencent/news/author/5933889" path="/tencent/news/author/:mid" :paramsDesc="['企鹅号 ID']"/>
## 贴吧
### 帖子列表
+3
View File
@@ -1682,4 +1682,7 @@ router.get('/sohu/mp/:id', require('./routes/sohu/mp'));
// 厚墨书源索引
router.get('/houmo/:code?', require('./routes/houmo/booksource'));
// 腾讯企鹅号
router.get('/tencent/news/author/:mid', require('./routes/tencent/news/author'));
module.exports = router;
+39
View File
@@ -0,0 +1,39 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const mid = ctx.params.mid;
const link = `https://new.qq.com/omn/author/${mid}`;
const api_url = `https://pacaio.match.qq.com/om/mediaArticles?mid=${mid}&num=15&page=0`;
const response = await got({
method: 'get',
url: api_url,
headers: { Referer: link },
});
const reponse = response.data;
const title = reponse.mediainfo.name;
const description = reponse.mediainfo.intro;
const list = reponse.data;
const items = list.map((item) => {
const title = item.title;
const date = Date(item.timestamp);
const itemUrl = item.vurl;
const author = item.source;
const description = item.abstract;
const single = {
title,
description,
link: itemUrl,
author,
pubDate: date,
};
return single;
});
ctx.state.data = {
title: title,
description: description,
link: link,
item: items,
};
};