-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
188 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding:utf-8 -*- | ||
# !/usr/bin/env python | ||
""" | ||
Date: 2023/8/7 20:20 | ||
Desc: 新浪财经-债券-可转债 | ||
https://money.finance.sina.com.cn/bond/info/sz128039.html | ||
""" | ||
import pandas as pd | ||
import requests | ||
|
||
|
||
def bond_cb_profile_sina(symbol: str = "sz128039") -> pd.DataFrame: | ||
""" | ||
新浪财经-债券-可转债-详情资料 | ||
https://money.finance.sina.com.cn/bond/info/sz128039.html | ||
:param symbol: 带市场标识的转债代码 | ||
:type symbol: str | ||
:return: 可转债-详情资料 | ||
:rtype: pandas.DataFrame | ||
""" | ||
url = f"https://money.finance.sina.com.cn/bond/info/{symbol}.html" | ||
r = requests.get(url) | ||
temp_df = pd.read_html(r.text)[0] | ||
temp_df.columns = ['item', 'value'] | ||
return temp_df | ||
|
||
|
||
def bond_cb_summary_sina(symbol: str = "sh155255") -> pd.DataFrame: | ||
""" | ||
新浪财经-债券-可转债-债券概况 | ||
https://money.finance.sina.com.cn/bond/quotes/sh155255.html | ||
:param symbol: 带市场标识的转债代码 | ||
:type symbol: str | ||
:return: 可转债-债券概况 | ||
:rtype: pandas.DataFrame | ||
""" | ||
url = f"https://money.finance.sina.com.cn/bond/quotes/{symbol}.html" | ||
r = requests.get(url) | ||
temp_df = pd.read_html(r.text)[10] | ||
part1 = temp_df.iloc[:, 0:2].copy() | ||
part1.columns = ["item", "value"] | ||
part2 = temp_df.iloc[:, 2:4].copy() | ||
part2.columns = ["item", "value"] | ||
part3 = temp_df.iloc[:, 4:6].copy() | ||
part3.columns = ["item", "value"] | ||
big_df = pd.concat([part1, part2, part3], ignore_index=True) | ||
return big_df | ||
|
||
|
||
if __name__ == "__main__": | ||
bond_cb_profile_sina_df = bond_cb_profile_sina(symbol="sz128039") | ||
print(bond_cb_profile_sina_df) | ||
|
||
bond_cb_summary_sina_df = bond_cb_summary_sina(symbol="sh155255") | ||
print(bond_cb_summary_sina_df) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters