diff --git a/akshare/__init__.py b/akshare/__init__.py index f085cbe5b90..f009593b2ba 100644 --- a/akshare/__init__.py +++ b/akshare/__init__.py @@ -1964,9 +1964,10 @@ 1.5.42 fix: fix stock_zt_pool_dtgc_em interface 1.5.43 fix: fix stock_zt_pool_em interface 1.5.44 fix: fix futures_to_spot_czce interface +1.5.45 add: add stock_hot_deal_xq interface """ -__version__ = "1.5.44" +__version__ = "1.5.45" __author__ = "AKFamily" import sys @@ -1977,6 +1978,20 @@ del sys +""" +股票热度-淘股吧 +""" +from akshare.stock_feature.stock_hot_tgb import stock_hot_tgb + +""" +股票热度-雪球 +""" +from akshare.stock_feature.stock_hot_xq import ( + stock_hot_deal_xq, + stock_hot_follow_xq, + stock_hot_tweet_xq, +) + """ 南华期货-板块指数涨跌 南华期货-品种指数涨跌 diff --git a/akshare/index/drewry_index.py b/akshare/index/drewry_index.py index 7ff932bdd85..b33a0feff43 100644 --- a/akshare/index/drewry_index.py +++ b/akshare/index/drewry_index.py @@ -2,7 +2,7 @@ # -*- coding:utf-8 -*- """ Date: 2021/9/23 15:38 -Desc: Drewry集装箱指数 +Desc: Drewry 集装箱指数 https://www.drewry.co.uk/supply-chain-advisors/supply-chain-expertise/world-container-index-assessed-by-drewry https://infogram.com/world-container-index-1h17493095xl4zj """ diff --git a/akshare/stock_feature/stock_hot_tgb.py b/akshare/stock_feature/stock_hot_tgb.py new file mode 100644 index 00000000000..8fbf91fb018 --- /dev/null +++ b/akshare/stock_feature/stock_hot_tgb.py @@ -0,0 +1,32 @@ +# -*- coding:utf-8 -*- +# !/usr/bin/env python +""" +Date: 2022/4/27 17:01 +Desc: 淘股吧-热门股票 +https://www.taoguba.com.cn/stock/moreHotStock +""" +import pandas as pd +import requests + + +def stock_hot_tgb() -> pd.DataFrame: + """ + 淘股吧-热门股票 + https://www.taoguba.com.cn/stock/moreHotStock + :return: 热门股票 + :rtype: pandas.DataFrame + """ + url = "https://www.taoguba.com.cn/stock/moreHotStock" + r = requests.get(url) + temp_df = pd.concat([pd.read_html(r.text, header=0)[0], pd.read_html(r.text, header=0)[1]]) + temp_df = temp_df[[ + "个股代码", + "个股名称", + ]] + temp_df.reset_index(inplace=True, drop=True) + return temp_df + + +if __name__ == '__main__': + stock_hot_tgb_df = stock_hot_tgb() + print(stock_hot_tgb_df) diff --git a/akshare/stock_feature/stock_hot_xq.py b/akshare/stock_feature/stock_hot_xq.py new file mode 100644 index 00000000000..6af534d66ac --- /dev/null +++ b/akshare/stock_feature/stock_hot_xq.py @@ -0,0 +1,248 @@ +# -*- coding:utf-8 -*- +# !/usr/bin/env python +""" +Date: 2022/4/27 17:01 +Desc: 雪球-沪深股市-热度排行榜 +https://xueqiu.com/hq +""" +import pandas as pd +import requests + + +def stock_hot_follow_xq(symbol: str = "本周新增") -> pd.DataFrame: + """ + 雪球-沪深股市-热度排行榜-关注排行榜 + https://xueqiu.com/hq + :param symbol: choice of {"本周新增", "最热门"} + :type symbol: str + :return: 关注排行榜 + :rtype: pandas.DataFrame + """ + symbol_map = { + "本周新增": "follow7d", + "最热门": "follow", + } + url = "https://xueqiu.com/service/v5/stock/screener/screen" + params = { + "category": "CN", + "size": "10000", + "order": "desc", + "order_by": symbol_map[symbol], + "only_count": "0", + "page": "1", + "_": "1651050034006", + } + headers = { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", + "Cache-Control": "no-cache", + "Connection": "keep-alive", + "Host": "xueqiu.com", + "Pragma": "no-cache", + "Referer": "https://xueqiu.com/hq", + "sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"Windows"', + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-origin", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36", + "X-Requested-With": "XMLHttpRequest", + } + r = requests.get(url, params=params, headers=headers) + data_json = r.json() + temp_df = pd.DataFrame(data_json["data"]["list"]) + if symbol == "本周新增": + temp_df = temp_df[ + [ + "symbol", + "name", + "follow7d", + "current", + ] + ] + else: + temp_df = temp_df[ + [ + "symbol", + "name", + "follow", + "current", + ] + ] + temp_df.columns = [ + "股票代码", + "股票简称", + "关注", + "最新价", + ] + temp_df["关注"] = pd.to_numeric(temp_df["关注"]) + temp_df["最新价"] = pd.to_numeric(temp_df["最新价"]) + return temp_df + + +def stock_hot_tweet_xq(symbol: str = "本周新增") -> pd.DataFrame: + """ + 雪球-沪深股市-热度排行榜-讨论排行榜 + https://xueqiu.com/hq + :param symbol: choice of {"本周新增", "最热门"} + :type symbol: str + :return: 讨论排行榜 + :rtype: pandas.DataFrame + """ + symbol_map = { + "本周新增": "tweet7d", + "最热门": "tweet", + } + url = "https://xueqiu.com/service/v5/stock/screener/screen" + params = { + "category": "CN", + "size": "10000", + "order": "desc", + "order_by": symbol_map[symbol], + "only_count": "0", + "page": "1", + "_": "1651050034006", + } + headers = { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", + "Cache-Control": "no-cache", + "Connection": "keep-alive", + "Host": "xueqiu.com", + "Pragma": "no-cache", + "Referer": "https://xueqiu.com/hq", + "sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"Windows"', + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-origin", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36", + "X-Requested-With": "XMLHttpRequest", + } + r = requests.get(url, params=params, headers=headers) + data_json = r.json() + temp_df = pd.DataFrame(data_json["data"]["list"]) + if symbol == "本周新增": + temp_df = temp_df[ + [ + "symbol", + "name", + "tweet7d", + "current", + ] + ] + else: + temp_df = temp_df[ + [ + "symbol", + "name", + "tweet", + "current", + ] + ] + temp_df.columns = [ + "股票代码", + "股票简称", + "关注", + "最新价", + ] + temp_df["关注"] = pd.to_numeric(temp_df["关注"]) + temp_df["最新价"] = pd.to_numeric(temp_df["最新价"]) + return temp_df + + +def stock_hot_deal_xq(symbol: str = "本周新增") -> pd.DataFrame: + """ + 雪球-沪深股市-热度排行榜-分享交易排行榜 + https://xueqiu.com/hq + :param symbol: choice of {"本周新增", "最热门"} + :type symbol: str + :return: 分享交易排行榜 + :rtype: pandas.DataFrame + """ + symbol_map = { + "本周新增": "deal7d", + "最热门": "deal", + } + url = "https://xueqiu.com/service/v5/stock/screener/screen" + params = { + "category": "CN", + "size": "10000", + "order": "desc", + "order_by": symbol_map[symbol], + "only_count": "0", + "page": "1", + "_": "1651050034006", + } + headers = { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", + "Cache-Control": "no-cache", + "Connection": "keep-alive", + "Host": "xueqiu.com", + "Pragma": "no-cache", + "Referer": "https://xueqiu.com/hq", + "sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"Windows"', + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-origin", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36", + "X-Requested-With": "XMLHttpRequest", + } + r = requests.get(url, params=params, headers=headers) + data_json = r.json() + temp_df = pd.DataFrame(data_json["data"]["list"]) + if symbol == "本周新增": + temp_df = temp_df[ + [ + "symbol", + "name", + "deal7d", + "current", + ] + ] + else: + temp_df = temp_df[ + [ + "symbol", + "name", + "deal", + "current", + ] + ] + temp_df.columns = [ + "股票代码", + "股票简称", + "关注", + "最新价", + ] + temp_df["关注"] = pd.to_numeric(temp_df["关注"]) + temp_df["最新价"] = pd.to_numeric(temp_df["最新价"]) + return temp_df + + +if __name__ == "__main__": + stock_hot_follow_xq_df = stock_hot_follow_xq(symbol="本周新增") + print(stock_hot_follow_xq_df) + + stock_hot_follow_xq_df = stock_hot_follow_xq(symbol="最热门") + print(stock_hot_follow_xq_df) + + stock_hot_tweet_xq_df = stock_hot_tweet_xq(symbol="本周新增") + print(stock_hot_tweet_xq_df) + + stock_hot_tweet_xq_df = stock_hot_tweet_xq(symbol="最热门") + print(stock_hot_tweet_xq_df) + + stock_hot_deal_xq_df = stock_hot_deal_xq(symbol="本周新增") + print(stock_hot_deal_xq_df) + + stock_hot_deal_xq_df = stock_hot_deal_xq(symbol="最热门") + print(stock_hot_deal_xq_df) diff --git a/docs/changelog.md b/docs/changelog.md index a6163276167..401c685875a 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,10 @@ ## 更新说明 +1.5.45 add: add stock_hot_deal_xq interface + + 1. 新增 stock_hot_deal_xq 接口,获取雪球-沪深股市-热度排行榜-分享交易排行榜数据 + 1.5.44 fix: fix futures_to_spot_czce interface 1. 修复 futures_to_spot_czce 接口,直接读取 Excel 文件并规范输出的字段类型 @@ -441,6 +445,8 @@ ## 版本更新说明 +1.5.45 add: add stock_hot_deal_xq interface + 1.5.44 fix: fix futures_to_spot_czce interface 1.5.43 fix: fix stock_zt_pool_em interface diff --git a/docs/data/stock/stock.md b/docs/data/stock/stock.md index 0ca86258832..937857f16fc 100644 --- a/docs/data/stock/stock.md +++ b/docs/data/stock/stock.md @@ -15170,6 +15170,161 @@ print(stock_board_industry_hist_min_em_df) ### 股票热度 +#### 股票热度-雪球 + +##### 关注排行榜 + +接口: stock_hot_follow_xq + +目标地址: https://xueqiu.com/hq + +描述: 雪球-沪深股市-热度排行榜-关注排行榜 + +限量: 单次返回所有股票的热度数据 + +输入参数 + +| 名称 | 类型 | 描述 | +|--------|-----|-----------------------------------------| +| symbol | str | symbol="最热门"; choice of {"本周新增", "最热门"} | + +输出参数 + +| 名称 | 类型 | 描述 | +|------|---------|---------| +| 股票代码 | object | - | +| 股票简称 | object | - | +| 关注 | float64 | - | +| 最新价 | float64 | 注意单位: 元 | + +接口示例 + +```python +import akshare as ak + +stock_hot_follow_xq_df = ak.stock_hot_follow_xq(symbol="最热门") +print(stock_hot_follow_xq_df) +``` + +数据示例 + +``` + 股票代码 股票简称 关注 最新价 +0 SH600519 贵州茅台 2305090.0 1794.92 +1 SH601318 中国平安 1964067.0 43.91 +2 SH600036 招商银行 1622413.0 38.04 +3 SZ000651 格力电器 1403675.0 30.46 +4 SZ000002 万科A 1110551.0 18.23 + ... ... ... ... +4884 BJ831689 克莱特 162.0 9.50 +4885 BJ832419 路斯股份 159.0 5.25 +4886 BJ873169 七丰精工 120.0 6.12 +4887 SZ000739 普洛药业 NaN 18.73 +4888 SZ001203 大中矿业 NaN 11.11 +``` + +##### 讨论排行榜 + +接口: stock_hot_tweet_xq + +目标地址: https://xueqiu.com/hq + +描述: 雪球-沪深股市-热度排行榜-讨论排行榜 + +限量: 单次返回所有股票的热度数据 + +输入参数 + +| 名称 | 类型 | 描述 | +|--------|-----|-----------------------------------------| +| symbol | str | symbol="最热门"; choice of {"本周新增", "最热门"} | + +输出参数 + +| 名称 | 类型 | 描述 | +|------|---------|---------| +| 股票代码 | object | - | +| 股票简称 | object | - | +| 关注 | float64 | - | +| 最新价 | float64 | 注意单位: 元 | + +接口示例 + +```python +import akshare as ak + +stock_hot_tweet_xq_df = ak.stock_hot_tweet_xq(symbol="最热门") +print(stock_hot_tweet_xq_df) +``` + +数据示例 + +``` + 股票代码 股票简称 关注 最新价 +0 SH600519 贵州茅台 255129.0 1794.92 +1 SH601919 中远海控 254436.0 13.93 +2 SZ300750 宁德时代 177185.0 407.05 +3 SZ002594 比亚迪 176794.0 235.01 +4 SZ000651 格力电器 162797.0 30.46 + ... ... ... ... +4884 BJ838924 广脉科技 0.0 6.30 +4885 BJ837212 智新电子 0.0 8.10 +4886 BJ831305 海希通讯 0.0 20.05 +4887 BJ830799 艾融软件 0.0 9.53 +4888 SZ001203 大中矿业 NaN 11.11 +``` + +##### 分享交易排行榜 + +接口: stock_hot_deal_xq + +目标地址: https://xueqiu.com/hq + +描述: 雪球-沪深股市-热度排行榜-分享交易排行榜 + +限量: 单次返回所有股票的热度数据 + +输入参数 + +| 名称 | 类型 | 描述 | +|--------|-----|-----------------------------------------| +| symbol | str | symbol="最热门"; choice of {"本周新增", "最热门"} | + +输出参数 + +| 名称 | 类型 | 描述 | +|------|---------|---------| +| 股票代码 | object | - | +| 股票简称 | object | - | +| 关注 | float64 | - | +| 最新价 | float64 | 注意单位: 元 | + +接口示例 + +```python +import akshare as ak + +stock_hot_deal_xq_df = ak.stock_hot_deal_xq(symbol="最热门") +print(stock_hot_deal_xq_df) +``` + +数据示例 + +``` + 股票代码 股票简称 关注 最新价 +0 SH601318 中国平安 529.0 43.91 +1 SZ000002 万科A 299.0 18.23 +2 SZ000651 格力电器 271.0 30.46 +3 SH600519 贵州茅台 263.0 1794.92 +4 SH600036 招商银行 217.0 38.04 + ... ... ... ... +4884 BJ838924 广脉科技 0.0 6.30 +4885 BJ837212 智新电子 0.0 8.10 +4886 BJ831305 海希通讯 0.0 20.05 +4887 BJ830799 艾融软件 0.0 9.53 +4888 SZ001203 大中矿业 NaN 11.11 +``` + #### 股票热度-问财 接口: stock_hot_rank_wc @@ -15277,6 +15432,64 @@ print(stock_hot_rank_em_df) 99 100 SZ002232 启明信息 17.36 -3.50 ``` +#### 股票热度-淘股吧 + +接口: stock_hot_tgb + +目标地址: https://www.taoguba.com.cn/stock/moreHotStock + +描述: 淘股吧-热门股票 + +限量: 单次返回排名前 20 股票 + +输入参数 + +| 名称 | 类型 | 描述 | +|-----|-----|-----| +| - | - | - | + +输出参数 + +| 名称 | 类型 | 描述 | +|------|---------|---------| +| 个股代码 | object | - | +| 个股名称 | object | - | + +接口示例 + +```python +import akshare as ak + +stock_hot_tgb_df = ak.stock_hot_tgb() +print(stock_hot_tgb_df) +``` + +数据示例 + +``` + 个股代码 个股名称 +0 sz002251 步步高 +1 sz000715 中兴商业 +2 sh605138 盛泰集团 +3 sh603696 安记食品 +4 sz001234 泰慕士 +5 sh600313 农发种业 +6 sz000736 中交地产 +7 sh603266 天龙股份 +8 sz000416 民生控股 +9 sh600508 上海能源 +10 sh601086 国芳集团 +11 sh600785 新华百货 +12 sz000722 湖南发展 +13 sh600630 龙头股份 +14 sh600938 中国海油 +15 sz002761 浙江建投 +16 sh600448 华纺股份 +17 sz000514 渝开发 +18 sz002264 新华都 +19 sz301088 戎美股份 +``` + #### 历史趋势及粉丝特征 接口: stock_hot_rank_detail_em diff --git a/docs/tutorial.md b/docs/tutorial.md index 2a2a36ffcfb..9a6d670f9e1 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -1062,6 +1062,12 @@ "futures_correlation_nh" # 相关系数矩阵 "futures_board_index_nh" # 板块指数涨跌 "futures_variety_index_nh" # 品种指数涨跌 + # 股票热度-雪球 + "stock_hot_follow_xq" # 雪球-沪深股市-热度排行榜-关注排行榜 + "stock_hot_tweet_xq" # 雪球-沪深股市-热度排行榜-讨论排行榜 + "stock_hot_deal_xq" # 雪球-沪深股市-热度排行榜-分享交易排行榜 + # 股票热度-淘股吧 + "stock_hot_tgb" # 淘股吧-热门股票 ``` ## 案例演示