From 5aed4ad4621fc4e45eadb5021253b193139d2842 Mon Sep 17 00:00:00 2001 From: jindaxiang Date: Thu, 2 Feb 2023 12:43:13 +0800 Subject: [PATCH] feat(stock_zyjs_ths.py): add stock_zyjs_ths interface add stock_zyjs_ths interface --- akshare/__init__.py | 8 +++- akshare/stock_fundamental/stock_zyjs_ths.py | 52 +++++++++++++++++++++ docs/changelog.md | 6 +++ docs/data/stock/stock.md | 42 +++++++++++++++++ docs/tutorial.md | 1 + 5 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 akshare/stock_fundamental/stock_zyjs_ths.py diff --git a/akshare/__init__.py b/akshare/__init__.py index 4276f4128b1..a5101704edc 100644 --- a/akshare/__init__.py +++ b/akshare/__init__.py @@ -2289,9 +2289,10 @@ 1.8.70 add: add stock_market_pe_lg interface 1.8.71 add: add stock_zygc_em interface 1.8.72 fix: fix drewry_wci_index interface +1.8.73 add: add stock_zyjs_ths interface """ -__version__ = "1.8.72" +__version__ = "1.8.73" __author__ = "AKFamily" import sys @@ -2303,6 +2304,11 @@ del sys +""" +主营介绍 +""" +from akshare.stock_fundamental.stock_zyjs_ths import stock_zyjs_ths + """ 东方财富-ETF 行情 """ diff --git a/akshare/stock_fundamental/stock_zyjs_ths.py b/akshare/stock_fundamental/stock_zyjs_ths.py new file mode 100644 index 00000000000..a2dacc51f58 --- /dev/null +++ b/akshare/stock_fundamental/stock_zyjs_ths.py @@ -0,0 +1,52 @@ +# -*- coding:utf-8 -*- +# !/usr/bin/env python +""" +Date: 2023/2/2 11:30 +Desc: 同花顺-主营介绍 +http://basic.10jqka.com.cn/new/000066/operate.html +""" +import pandas as pd +import requests +from bs4 import BeautifulSoup + + +def stock_zyjs_ths(symbol: str = "000066") -> pd.DataFrame: + """ + 同花顺-主营介绍 + http://basic.10jqka.com.cn/new/000066/operate.html + :param symbol: 股票代码 + :type symbol: str + :return: 主营构成 + :rtype: pandas.DataFrame + """ + url = f"http://basic.10jqka.com.cn/new/{symbol}/operate.html" + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" + } + r = requests.get(url, headers=headers) + r.encoding = "gb2312" + soup = BeautifulSoup(r.text, "lxml") + content_list = [ + item.text.strip() + for item in soup.find("ul", attrs={"class": "main_intro_list"}).find_all("li") + ] + columns_list = [] + value_list = [] + for item in content_list: + columns_list.append(item.split(":")[0]) + value_list.append( + item.split(":", maxsplit=1)[1] + .replace("\t", "") + .replace("\n", "") + .replace(" ", "") + .strip() + ) + + temp_df = pd.DataFrame(value_list, index=columns_list).T + temp_df.insert(0, "股票代码", symbol) + return temp_df + + +if __name__ == "__main__": + stock_zyjs_ths_df = stock_zyjs_ths(symbol="000066") + print(stock_zyjs_ths_df) diff --git a/docs/changelog.md b/docs/changelog.md index a94194a29f0..ecb7fc90e5d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -49,6 +49,10 @@ ## 更新说明 +1.8.73 add: add stock_zyjs_ths interface + + 1. 新增 stock_zyjs_ths 接口 + 1.8.72 fix: fix drewry_wci_index interface 1. 修复 drewry_wci_index 接口 @@ -1838,6 +1842,8 @@ ## 版本更新说明 +1.8.73 add: add stock_zyjs_ths interface + 1.8.72 fix: fix drewry_wci_index interface 1.8.71 add: add stock_zygc_em interface diff --git a/docs/data/stock/stock.md b/docs/data/stock/stock.md index 1f8e08fd7c1..7f5a7ced505 100644 --- a/docs/data/stock/stock.md +++ b/docs/data/stock/stock.md @@ -4357,6 +4357,48 @@ print(stock_jgdy_detail_em_df) 623 624 300718 长盛轴承 ... 浙江长盛滑动轴承股份有限公司 2021-09-16 2021-09-16 ``` +### 主营介绍-同花顺 + +接口: stock_zyjs_ths + +目标地址: http://basic.10jqka.com.cn/new/000066/operate.html + +描述: 同花顺-主营介绍 + +限量: 单次返回所有数据 + +输入参数 + +| 名称 | 类型 | 描述 | +|--------|-----|-----------------| +| symbol | str | symbol="000066" | + +输出参数 + +| 名称 | 类型 | 描述 | +|------|---------|---------| +| 股票代码 | object | - | +| 主营业务 | object | - | +| 产品类型 | object | - | +| 产品名称 | object | - | +| 经营范围 | object | - | + +接口示例 + +```python +import akshare as ak + +stock_zyjs_ths_df = ak.stock_zyjs_ths(symbol="000066") +print(stock_zyjs_ths_df) +``` + +数据示例 + +``` + 股票代码 ... 经营范围 +0 000066 ... 计算机软件、硬件、终端及其外部设备、网络系统及系统集成、电子产品及零部件、金融机具、税控机具... +``` + ### 主营构成-东财 接口: stock_zygc_em diff --git a/docs/tutorial.md b/docs/tutorial.md index ec0b68a9ee3..548e5c1adc1 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -1196,6 +1196,7 @@ "fund_stock_position_lg" # 乐咕乐股-基金仓位-股票型基金仓位 "fund_balance_position_lg" # 乐咕乐股-基金仓位-平衡混合型基金仓位 "fund_linghuo_position_lg" # 乐咕乐股-基金仓位-灵活配置型基金仓位 + "stock_zyjs_ths" # 主营介绍 ``` ## 案例演示