Skip to content

Commit

Permalink
feat(stock_zyjs_ths.py): add stock_zyjs_ths interface
Browse files Browse the repository at this point in the history
add stock_zyjs_ths interface
  • Loading branch information
albertandking committed Feb 2, 2023
1 parent bb9a4a8 commit 5aed4ad
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 1 deletion.
8 changes: 7 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -2303,6 +2304,11 @@

del sys

"""
主营介绍
"""
from akshare.stock_fundamental.stock_zyjs_ths import stock_zyjs_ths

"""
东方财富-ETF 行情
"""
Expand Down
52 changes: 52 additions & 0 deletions akshare/stock_fundamental/stock_zyjs_ths.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 接口
Expand Down Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions docs/data/stock/stock.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@
"fund_stock_position_lg" # 乐咕乐股-基金仓位-股票型基金仓位
"fund_balance_position_lg" # 乐咕乐股-基金仓位-平衡混合型基金仓位
"fund_linghuo_position_lg" # 乐咕乐股-基金仓位-灵活配置型基金仓位
"stock_zyjs_ths" # 主营介绍
```

## 案例演示
Expand Down

0 comments on commit 5aed4ad

Please sign in to comment.