路由添加 金融:有知有行 (#8705)

This commit is contained in:
metaJS
2022-01-22 19:05:25 +00:00
committed by GitHub
parent a4b0476788
commit 03d527de81
3 changed files with 38 additions and 0 deletions
+7
View File
@@ -261,6 +261,13 @@ pageClass: routes
<Route author="zytomorrow" example="/xueqiu/stock_comments/SZ002626" path="/xueqiu/stock_comments/:id/:titleLength?" :paramsDesc="['股票代码(需要带上交易所)', '标题长度']"/>
## 有知有行
### 有知文章
<Route author="broven" example="/youzhiyouxing/materials" path="/youzhiyouxing/materials" />
## 证券时报网
### 要闻
+2
View File
@@ -2129,6 +2129,8 @@ router.get('/weidian/goods/:id', lazyloadRouteHandler('./routes/weidian/goods'))
// 有赞
router.get('/youzan/goods/:id', lazyloadRouteHandler('./routes/youzan/goods'));
// 有知有行
router.get('/youzhiyouxing/materials', lazyloadRouteHandler('./routes/youzhiyouxing/materials'));
// 币世界快讯
router.get('/bishijie/kuaixun', lazyloadRouteHandler('./routes/bishijie/kuaixun'));
+29
View File
@@ -0,0 +1,29 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const link = `https://youzhiyouxing.cn/materials`;
const response = await got({
method: 'get',
url: link,
});
const $ = cheerio.load(response.data);
const list = $('[phx-click=material]');
const resData = {
title: '有知有行 - 有知',
link,
description: '有知有行 - 有知',
item: list
.map((_index, item) => {
const $item = $(item);
const res = {
title: $item.find('.title-bar > h3').text(),
description: $item.find('.sm-text').text(),
link: `https://youzhiyouxing.cn/materials/${$item.attr('phx-value-id')}`,
};
return res;
})
.get(),
};
ctx.state.data = resData;
};