mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: 添加对 鲸跃汽车文章 的支持 (#3150)
This commit is contained in:
@@ -375,6 +375,16 @@ pageClass: routes
|
||||
|
||||
<Route author="LogicJake" example="/whalegogo/home" path="/whalegogo/home"/>
|
||||
|
||||
### 其他栏目
|
||||
|
||||
<Route author="Jeason0228" example="/whalegogo/portal" path="/whalegogo/portal/:type_id/:tagid?/" :paramsDesc="['type_id,栏目id','tagid,标签id']">
|
||||
|
||||
| 快讯 | 文章 | 活动 | 评测 | 视频 | 访谈 |
|
||||
| -------------------- | -------------------- | -------------------- | -------------------- | ------------------ | ------------------ |
|
||||
| type_id=2,tagid 不填 | type_id=1,tagid 不填 | type_id=7,tagid 不填 | type_id=8,tagid 不填 | type_id=1,tagid=70 | type_id=1,tagid=73 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 巨潮资讯
|
||||
|
||||
### 公司公告
|
||||
|
||||
@@ -1089,6 +1089,7 @@ router.get('/wenku8/chapter/:id', require('./routes/wenku8/chapter'));
|
||||
|
||||
// 鲸跃汽车
|
||||
router.get('/whalegogo/home', require('./routes/whalegogo/home'));
|
||||
router.get('/whalegogo/portal/:type_id/:tagid?/', require('./routes/whalegogo/portal'));
|
||||
|
||||
// 爱思想
|
||||
router.get('/aisixiang/column/:id', require('./routes/aisixiang/column'));
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
const got = require('@/utils/got');
|
||||
module.exports = async (ctx) => {
|
||||
const type_id = ctx.params.type_id || '2';
|
||||
const tagid = ctx.params.tagid || '';
|
||||
const sort = ctx.params.sort || '-push_at';
|
||||
const url = `https://www.whalegogo.com/list/portal-${type_id}?tag_id=all`;
|
||||
// type_id = 2:快讯 / 1:文章 / 7:活动 / 8:评测
|
||||
// tagid = 70:视频 /73:访谈
|
||||
// sort = -push_at 最新 / hot最热
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.whalegogo.com/v1/articles/search?tagid=${tagid}&type_id=${type_id}&sort=${sort}&page=1&per-page=12`,
|
||||
headers: {
|
||||
Referer: url,
|
||||
},
|
||||
});
|
||||
const list = response.data.items;
|
||||
const out = await Promise.all(
|
||||
list.map(async (info) => {
|
||||
const title = info.title;
|
||||
const date = info.push_at;
|
||||
const id = info.id;
|
||||
// const cid = info.cid;
|
||||
const author = info.author.username;
|
||||
const itemUrl = `https://www.whalegogo.com/news?id=${id}`;
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
// console.log(cid);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.whalegogo.com/v1/articles/${id}?expand=content`,
|
||||
headers: {
|
||||
Referer: url,
|
||||
},
|
||||
});
|
||||
const description = response.data.content;
|
||||
|
||||
const single = {
|
||||
title: title,
|
||||
author,
|
||||
link: itemUrl,
|
||||
description: description,
|
||||
pubDate: new Date(date * 1000).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '鲸跃汽车',
|
||||
link: url,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user