mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 20:27:52 +08:00
feat: add finviz stock news (#4075)
This commit is contained in:
11
docs/en/finance.md
Normal file
11
docs/en/finance.md
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
pageClass: routes
|
||||
---
|
||||
|
||||
# Finance
|
||||
|
||||
## finviz
|
||||
|
||||
### US stock news
|
||||
|
||||
<Route author="HenryQW" example="/finviz/news/AAPL" path="/finviz/news/:ticker" :paramsDesc="['The stock ticker']"/>
|
||||
59
docs/finance.md
Normal file
59
docs/finance.md
Normal file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
pageClass: routes
|
||||
---
|
||||
|
||||
# 金融
|
||||
|
||||
## 雪球
|
||||
|
||||
### 用户动态
|
||||
|
||||
<Route author="imlonghao" example="/xueqiu/user/8152922548" path="/xueqiu/user/:id/:type?" :paramsDesc="['用户 id, 可在用户主页 URL 中找到', '动态的类型, 不填则默认全部']">
|
||||
|
||||
| 原发布 | 长文 | 问答 | 热门 | 交易 |
|
||||
| ------ | ---- | ---- | ---- | ---- |
|
||||
| 0 | 2 | 4 | 9 | 11 |
|
||||
|
||||
</Route>
|
||||
|
||||
### 用户收藏动态
|
||||
|
||||
<Route author="imlonghao" example="/xueqiu/favorite/8152922548" path="/xueqiu/favorite/:id" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']"/>
|
||||
|
||||
### 用户自选动态
|
||||
|
||||
<Route author="hillerliao" example="/xueqiu/user_stock/1247347556" path="/xueqiu/user_stock/:id" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']"/>
|
||||
|
||||
### 基金净值更新
|
||||
|
||||
<Route author="HenryQW" example="/xueqiu/fund/040008" path="/xueqiu/fund/:id" :paramsDesc="['基金代码, 可在基金主页 URL 中找到. 此路由的数据为场外基金 (`F`开头)']"/>
|
||||
|
||||
### 组合最新调仓信息
|
||||
|
||||
<Route author="ZhishanZhang" example="/xueqiu/p/ZH1288184" path="/xueqiu/snb/:id" :paramsDesc="['组合代码, 可在组合主页 URL 中找到.']"/>
|
||||
|
||||
### 股票信息
|
||||
|
||||
<Route author="YuYang" example="/xueqiu/stock_info/SZ000002" path="/xueqiu/stock_info/:id/:type?" :paramsDesc="['股票代码(需要带上交易所)', '动态的类型, 不填则为股票公告']">
|
||||
|
||||
| 公告 | 新闻 | 研报 |
|
||||
| ------------ | ---- | -------- |
|
||||
| announcement | news | research |
|
||||
|
||||
</Route>
|
||||
|
||||
## 淘股吧股票论坛
|
||||
|
||||
### 论坛总版
|
||||
|
||||
<Route author="emdoe" example="/taoguba/index" path="/taoguba/index"/>
|
||||
|
||||
### 用户博客
|
||||
|
||||
<Route author="emdoe" example="/taoguba/user/252069" path="/taoguba/user/:uid" :paramsDesc="['用户 id']" />
|
||||
|
||||
## finviz
|
||||
|
||||
### 美股股票新闻
|
||||
|
||||
<Route author="HenryQW" example="/finviz/news/AAPL" path="/finviz/news/:ticker" :paramsDesc="['股票代码']"/>
|
||||
@@ -372,16 +372,6 @@ type 为 all 时,category 参数不支持 cost 和 free
|
||||
|
||||
<Route author="xyqfer" example="/sogou/doodles" path="/sogou/doodles"/>
|
||||
|
||||
## 淘股吧股票论坛
|
||||
|
||||
### 论坛总版
|
||||
|
||||
<Route author="emdoe" example="/taoguba/index" path="/taoguba/index"/>
|
||||
|
||||
### 用户博客
|
||||
|
||||
<Route author="emdoe" example="/taoguba/user/252069" path="/taoguba/user/:uid" :paramsDesc="['用户 id']" />
|
||||
|
||||
## 腾讯吐个槽
|
||||
|
||||
### 吐槽新帖
|
||||
|
||||
@@ -780,44 +780,6 @@ rule
|
||||
|
||||
<Route author="kt286" example="/weibo/oasis/user/1990895721" path="/weibo/oasis/user/:userid" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']" anticrawler="1"/>
|
||||
|
||||
## 雪球
|
||||
|
||||
### 用户动态
|
||||
|
||||
<Route author="imlonghao" example="/xueqiu/user/8152922548" path="/xueqiu/user/:id/:type?" :paramsDesc="['用户 id, 可在用户主页 URL 中找到', '动态的类型, 不填则默认全部']">
|
||||
|
||||
| 原发布 | 长文 | 问答 | 热门 | 交易 |
|
||||
| ------ | ---- | ---- | ---- | ---- |
|
||||
| 0 | 2 | 4 | 9 | 11 |
|
||||
|
||||
</Route>
|
||||
|
||||
### 用户收藏动态
|
||||
|
||||
<Route author="imlonghao" example="/xueqiu/favorite/8152922548" path="/xueqiu/favorite/:id" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']"/>
|
||||
|
||||
### 用户自选动态
|
||||
|
||||
<Route author="hillerliao" example="/xueqiu/user_stock/1247347556" path="/xueqiu/user_stock/:id" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']"/>
|
||||
|
||||
### 基金净值更新
|
||||
|
||||
<Route author="HenryQW" example="/xueqiu/fund/040008" path="/xueqiu/fund/:id" :paramsDesc="['基金代码, 可在基金主页 URL 中找到. 此路由的数据为场外基金 (`F`开头)']"/>
|
||||
|
||||
### 组合最新调仓信息
|
||||
|
||||
<Route author="ZhishanZhang" example="/xueqiu/p/ZH1288184" path="/xueqiu/snb/:id" :paramsDesc="['组合代码, 可在组合主页 URL 中找到.']"/>
|
||||
|
||||
### 股票信息
|
||||
|
||||
<Route author="YuYang" example="/xueqiu/stock_info/SZ000002" path="/xueqiu/stock_info/:id/:type?" :paramsDesc="['股票代码(需要带上交易所)', '动态的类型, 不填则为股票公告']">
|
||||
|
||||
| 公告 | 新闻 | 研报 |
|
||||
| ------------ | ---- | -------- |
|
||||
| announcement | news | research |
|
||||
|
||||
</Route>
|
||||
|
||||
### 热帖
|
||||
|
||||
<Route author="hillerliao" example="/xueqiu/hots" path="/xueqiu/hots"/>
|
||||
|
||||
@@ -2259,6 +2259,10 @@ router.get('/google/news/:category/:locale', require('./routes/google/news'));
|
||||
router.get('/p-articles/section/:section', require('./routes/p-articles/section'));
|
||||
router.get('/p-articles/contributors/:author', require('./routes/p-articles/contributors'));
|
||||
|
||||
// finviz
|
||||
|
||||
router.get('/finviz/news/:ticker', require('./routes/finviz/news'));
|
||||
|
||||
// 好好住
|
||||
router.get('/haohaozhu/whole-house/:keyword?', require('./routes/haohaozhu/whole-house'));
|
||||
router.get('/haohaozhu/discover/:keyword?', require('./routes/haohaozhu/discover'));
|
||||
|
||||
50
lib/routes/finviz/news.js
Normal file
50
lib/routes/finviz/news.js
Normal file
@@ -0,0 +1,50 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const dateParser = require('@/utils/dateParser');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `https://finviz.com/quote.ashx?t=${ctx.params.ticker}`;
|
||||
const response = await got.get(link);
|
||||
|
||||
const $ = cheerio.load(response.body);
|
||||
const data = $('table.fullview-news-outer tr').slice(0, 10);
|
||||
|
||||
let dateRow = '';
|
||||
const item = await Promise.all(
|
||||
data
|
||||
.map(async (i, e) => {
|
||||
let date = $(e)
|
||||
.find('td')
|
||||
.first()
|
||||
.text()
|
||||
.trim();
|
||||
if (date.includes('-')) {
|
||||
dateRow = date.split(' ')[0];
|
||||
} else {
|
||||
date = `${dateRow} ${date}`;
|
||||
}
|
||||
return {
|
||||
title: $(e)
|
||||
.find('a')
|
||||
.text(),
|
||||
pubDate: dateParser(date, 'MMM-DD-YY HH:mmA'),
|
||||
authors: $(e)
|
||||
.find('span')
|
||||
.text(),
|
||||
link: $(e)
|
||||
.find('a')
|
||||
.attr('href'),
|
||||
};
|
||||
})
|
||||
.get()
|
||||
);
|
||||
|
||||
const name = $('.fullview-title b').text();
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name} News by Finviz`,
|
||||
link,
|
||||
description: `A collection of ${name} news aggregated by Finviz.`,
|
||||
item,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user