feat: 8btc newsflash && xuangubao subject (#3059)
This commit is contained in:
parent
3f97107dae
commit
32ea59134c
|
|
@ -176,6 +176,10 @@ pageClass: routes
|
|||
|
||||
<Route author="kt286" example="/8btc/45703" path="/8btc/:authorid" :paramsDesc="['作者ID,可在对应专辑页面的 URL 中找到']"/>
|
||||
|
||||
### 快讯
|
||||
|
||||
<Route author="hillerliao" example="/8btc/news/flash" path="/8btc/news/flash"/>
|
||||
|
||||
## 币世界
|
||||
|
||||
### 快讯
|
||||
|
|
@ -391,6 +395,10 @@ pageClass: routes
|
|||
|
||||
<Route author="hillerliao" example="/cninfo/fund_announcement/159977/基金合同" path="/cninfo/fund_announcement/:code/:searchkey" :paramsDesc="['基金代码, 若不指定则填 all', '过滤词,若不指定则填all']"/>
|
||||
|
||||
## 选股宝
|
||||
|
||||
<Route author="hillerliao" example="/xuangubao/subject/41" path="/xuangubao/subject/:subject_id" :paramsDesc="['主题 id,网址 https://xuangubao.cn/subject/41 中最后的数字']" />
|
||||
|
||||
## 决胜网
|
||||
|
||||
### 最新资讯
|
||||
|
|
|
|||
|
|
@ -376,6 +376,9 @@ router.get('/wikipedia/mainland', require('./routes/wikipedia/mainland'));
|
|||
// 联合国 United Nations
|
||||
router.get('/un/scveto', require('./routes/un/scveto'));
|
||||
|
||||
// 选股宝
|
||||
router.get('/xuangubao/subject/:subject_id', require('./routes/xuangubao/subject'));
|
||||
|
||||
// 雪球
|
||||
router.get('/xueqiu/user/:id/:type?', require('./routes/xueqiu/user'));
|
||||
router.get('/xueqiu/favorite/:id', require('./routes/xueqiu/favorite'));
|
||||
|
|
@ -1469,6 +1472,7 @@ router.get('/topys/:category', require('./routes/topys/article'));
|
|||
|
||||
// 巴比特作者专栏
|
||||
router.get('/8btc/:authorid', require('./routes/8btc/author'));
|
||||
router.get('/8btc/news/flash', require('./routes/8btc/news/flash'));
|
||||
|
||||
// VueVlog
|
||||
router.get('/vuevideo/:userid', require('./routes/vuevideo/user'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://app.blockmeta.com/w1/news/list?num=30&cat_id=4481&page=1`,
|
||||
headers: {
|
||||
from: 'web',
|
||||
Referer: `https://www.8btc.com/flash`,
|
||||
},
|
||||
});
|
||||
|
||||
const newsflashes = response.data.list;
|
||||
|
||||
let newsflashesList = [];
|
||||
for (let i = 0; i < newsflashes.length; i++) {
|
||||
newsflashesList = newsflashesList.concat(newsflashes[i]);
|
||||
}
|
||||
|
||||
const out = newsflashesList.map((item) => {
|
||||
const pubDate = item.post_date_format;
|
||||
const link = item.source.link;
|
||||
const title = item.title;
|
||||
const description = item.content;
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link,
|
||||
pubDate,
|
||||
description,
|
||||
};
|
||||
|
||||
return single;
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `快讯 - 巴比特`,
|
||||
link: `https://www.8btc.com/flash`,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const subject_id = ctx.params.subject_id;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.xuangubao.cn/api/pc/subj/${subject_id}?limit=20`,
|
||||
headers: {
|
||||
Referer: `https://xuangubao.cn/subject/${subject_id}`,
|
||||
},
|
||||
});
|
||||
|
||||
const subject = response.data.Subject;
|
||||
const subject_title = subject.Title;
|
||||
const subject_desc = subject.Desc;
|
||||
|
||||
const messages = response.data.Messages;
|
||||
|
||||
let messagesList = [];
|
||||
for (let i = 0; i < messages.length; i++) {
|
||||
messagesList = messagesList.concat(messages[i]);
|
||||
}
|
||||
|
||||
const out = messagesList.map((item) => {
|
||||
const date = item.CreatedAt;
|
||||
const link = item.OriginalUrl;
|
||||
const title = item.Title;
|
||||
const description = item.Summary;
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link,
|
||||
pubDate: date,
|
||||
description,
|
||||
};
|
||||
|
||||
return single;
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${subject_title} - 主题 - 选股宝`,
|
||||
link: `https://xuangubao.cn/subject/${subject_id}`,
|
||||
description: `${subject_desc}`,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue