akshare 1.12.99__py3-none-any.whl → 1.15.73__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of akshare might be problematic. Click here for more details.
- akshare/__init__.py +442 -138
- akshare/air/air_hebei.py +79 -53
- akshare/air/air_zhenqi.py +29 -43
- akshare/air/sunrise_tad.py +32 -17
- akshare/bank/bank_cbirc_2020.py +12 -9
- akshare/bond/bond_cb_ths.py +17 -9
- akshare/bond/bond_china.py +38 -39
- akshare/bond/bond_china_money.py +75 -48
- akshare/bond/bond_info_cm.py +28 -8
- akshare/bond/bond_issue_cninfo.py +73 -30
- akshare/bond/bond_zh_cov.py +1 -1
- akshare/bond/bond_zh_sina.py +57 -51
- akshare/cal/__init__.py +0 -0
- akshare/cal/rv.py +170 -0
- akshare/cost/cost_living.py +7 -5
- akshare/currency/currency_safe.py +7 -6
- akshare/data/cninfo.js +15 -0
- akshare/datasets.py +10 -21
- akshare/economic/macro_bank.py +95 -653
- akshare/economic/macro_china.py +772 -1024
- akshare/economic/macro_china_hk.py +65 -243
- akshare/economic/macro_china_nbs.py +24 -7
- akshare/economic/macro_constitute.py +17 -12
- akshare/economic/macro_euro.py +13 -6
- akshare/economic/macro_finance_ths.py +133 -0
- akshare/economic/macro_info_ws.py +100 -0
- akshare/economic/macro_japan.py +5 -4
- akshare/economic/macro_other.py +12 -9
- akshare/economic/macro_usa.py +376 -1940
- akshare/economic/marco_cnbs.py +11 -6
- akshare/energy/energy_carbon.py +94 -125
- akshare/event/migration.py +3 -2
- akshare/exceptions.py +43 -0
- akshare/file_fold/calendar.json +245 -2
- akshare/fortune/fortune_500.py +15 -48
- akshare/fund/fund_amac.py +157 -75
- akshare/fund/fund_em.py +191 -184
- akshare/fund/fund_etf_em.py +16 -15
- akshare/fund/fund_etf_sina.py +71 -23
- akshare/fund/fund_etf_ths.py +93 -0
- akshare/fund/fund_fee_em.py +98 -0
- akshare/fund/fund_portfolio_em.py +60 -50
- akshare/fund/fund_rank_em.py +91 -82
- akshare/fund/fund_report_cninfo.py +63 -48
- akshare/fund/fund_scale_sina.py +20 -10
- akshare/fund/fund_xq.py +139 -109
- akshare/futures/cons.py +8 -31
- akshare/futures/cot.py +185 -137
- akshare/futures/futures_basis.py +97 -32
- akshare/futures/futures_comm_ctp.py +37 -0
- akshare/futures/futures_comm_qihuo.py +74 -45
- akshare/futures/futures_daily_bar.py +121 -184
- akshare/futures/futures_hf_em.py +66 -61
- akshare/futures/futures_hq_sina.py +79 -61
- akshare/futures/futures_index_ccidx.py +6 -3
- akshare/futures/futures_inventory_99.py +61 -272
- akshare/futures/futures_news_shmet.py +4 -2
- akshare/futures/futures_roll_yield.py +12 -25
- akshare/futures/futures_spot_stock_em.py +19 -13
- akshare/futures/futures_stock_js.py +14 -12
- akshare/futures/futures_to_spot.py +38 -33
- akshare/futures/futures_warehouse_receipt.py +75 -71
- akshare/futures/futures_zh_sina.py +5 -5
- akshare/futures/symbol_var.py +18 -13
- akshare/futures_derivative/futures_contract_info_czce.py +60 -52
- akshare/futures_derivative/futures_contract_info_ine.py +43 -34
- akshare/futures_derivative/futures_contract_info_shfe.py +46 -35
- akshare/futures_derivative/futures_cot_sina.py +26 -19
- akshare/futures_derivative/futures_spot_sys.py +21 -8
- akshare/fx/currency_investing.py +19 -285
- akshare/index/index_cflp.py +29 -26
- akshare/index/index_cni.py +86 -88
- akshare/index/index_cons.py +26 -10
- akshare/index/index_cx.py +248 -47
- akshare/index/index_drewry.py +17 -16
- akshare/index/index_option_qvix.py +329 -0
- akshare/index/index_research_fund_sw.py +134 -0
- akshare/index/{index_sw_research.py → index_research_sw.py} +122 -58
- akshare/index/index_spot.py +9 -5
- akshare/index/index_stock_hk.py +35 -16
- akshare/index/index_stock_us_sina.py +1 -1
- akshare/index/index_stock_zh.py +180 -89
- akshare/index/index_stock_zh_csindex.py +15 -369
- akshare/index/index_sw.py +62 -34
- akshare/index/index_yw.py +46 -23
- akshare/index/index_zh_a_scope.py +48 -0
- akshare/index/index_zh_em.py +6 -4
- akshare/interest_rate/interbank_rate_em.py +14 -9
- akshare/movie/artist_yien.py +32 -5
- akshare/movie/movie_yien.py +92 -18
- akshare/movie/video_yien.py +28 -5
- akshare/news/news_baidu.py +78 -44
- akshare/news/news_cctv.py +38 -38
- akshare/news/news_stock.py +6 -3
- akshare/nlp/nlp_interface.py +7 -8
- akshare/option/cons.py +11 -11
- akshare/option/option_comm_qihuo.py +86 -0
- akshare/option/option_commodity.py +178 -51
- akshare/option/option_daily_stats_sse_szse.py +146 -0
- akshare/option/option_em.py +147 -138
- akshare/option/option_finance_sina.py +160 -137
- akshare/option/option_lhb_em.py +62 -56
- akshare/option/option_risk_indicator_sse.py +17 -14
- akshare/other/other_car_cpca.py +934 -0
- akshare/other/{other_car.py → other_car_gasgoo.py} +15 -54
- akshare/qdii/__init__.py +0 -0
- akshare/qdii/qdii_jsl.py +233 -0
- akshare/request.py +117 -0
- akshare/spot/spot_hog_soozhu.py +232 -0
- akshare/spot/spot_price_qh.py +121 -0
- akshare/spot/spot_sge.py +63 -10
- akshare/stock/stock_allotment_cninfo.py +10 -9
- akshare/stock/stock_board_concept_em.py +23 -14
- akshare/stock/stock_board_industry_em.py +40 -34
- akshare/stock/stock_cg_equity_mortgage.py +15 -11
- akshare/stock/stock_cg_guarantee.py +41 -51
- akshare/stock/stock_cg_lawsuit.py +36 -35
- akshare/stock/stock_dividend_cninfo.py +12 -6
- akshare/stock/stock_dzjy_em.py +347 -260
- akshare/stock/stock_fund_em.py +332 -84
- akshare/stock/stock_hk_famous.py +108 -0
- akshare/stock/stock_hk_sina.py +8 -7
- akshare/stock/stock_hold_control_cninfo.py +100 -15
- akshare/stock/stock_hold_control_em.py +4 -3
- akshare/stock/stock_hold_num_cninfo.py +18 -12
- akshare/stock/stock_hot_rank_em.py +2 -1
- akshare/stock/stock_hot_search_baidu.py +5 -2
- akshare/stock/stock_industry_cninfo.py +24 -18
- akshare/stock/stock_industry_pe_cninfo.py +45 -31
- akshare/stock/stock_industry_sw.py +9 -10
- akshare/stock/stock_info.py +25 -15
- akshare/stock/stock_info_em.py +5 -2
- akshare/stock/stock_intraday_em.py +5 -2
- akshare/stock/stock_intraday_sina.py +22 -18
- akshare/stock/stock_ipo_summary_cninfo.py +25 -10
- akshare/stock/stock_new_cninfo.py +32 -19
- akshare/stock/stock_news_cx.py +39 -0
- akshare/stock/stock_profile_cninfo.py +9 -8
- akshare/stock/stock_rank_forecast.py +8 -6
- akshare/stock/stock_share_changes_cninfo.py +18 -14
- akshare/stock/stock_share_hold.py +24 -19
- akshare/stock/stock_summary.py +54 -26
- akshare/stock/stock_us_famous.py +15 -6
- akshare/stock/stock_us_pink.py +7 -5
- akshare/stock/stock_us_sina.py +15 -12
- akshare/stock/stock_xq.py +38 -12
- akshare/stock/stock_zh_a_sina.py +53 -78
- akshare/stock/stock_zh_b_sina.py +32 -55
- akshare/stock/stock_zh_kcb_report.py +11 -9
- akshare/stock/stock_zh_kcb_sina.py +67 -64
- akshare/stock_feature/stock_a_below_net_asset_statistics.py +5 -2
- akshare/stock_feature/stock_a_high_low.py +5 -2
- akshare/stock_feature/stock_a_indicator.py +12 -9
- akshare/stock_feature/stock_a_pe_and_pb.py +27 -6
- akshare/stock_feature/stock_account_em.py +58 -40
- akshare/stock_feature/stock_analyst_em.py +36 -27
- akshare/stock_feature/stock_board_industry_ths.py +136 -400
- akshare/stock_feature/stock_comment_em.py +118 -85
- akshare/stock_feature/stock_concept_futu.py +183 -0
- akshare/stock_feature/stock_cyq_em.py +58 -54
- akshare/stock_feature/stock_disclosure_cninfo.py +147 -102
- akshare/stock_feature/stock_esg_sina.py +216 -11
- akshare/stock_feature/stock_fhps_em.py +60 -25
- akshare/stock_feature/stock_fhps_ths.py +25 -6
- akshare/stock_feature/stock_fund_flow.py +38 -25
- akshare/stock_feature/stock_gdfx_em.py +180 -95
- akshare/stock_feature/stock_gdhs.py +73 -49
- akshare/stock_feature/stock_gpzy_em.py +78 -46
- akshare/stock_feature/stock_hist_em.py +55 -23
- akshare/stock_feature/stock_hk_valuation_baidu.py +20 -8
- akshare/stock_feature/stock_hsgt_em.py +184 -452
- akshare/stock_feature/stock_info.py +52 -29
- akshare/stock_feature/stock_inner_trade_xq.py +39 -31
- akshare/stock_feature/stock_irm_cninfo.py +32 -9
- akshare/stock_feature/stock_jgdy_em.py +41 -38
- akshare/stock_feature/stock_lh_yybpm.py +36 -37
- akshare/stock_feature/stock_lhb_em.py +135 -71
- akshare/stock_feature/stock_lhb_sina.py +93 -46
- akshare/stock_feature/stock_margin_em.py +102 -0
- akshare/stock_feature/{stock_sse_margin.py → stock_margin_sse.py} +21 -15
- akshare/stock_feature/{stock_szse_margin.py → stock_margin_szse.py} +23 -19
- akshare/stock_feature/stock_market_legu.py +13 -8
- akshare/stock_feature/stock_pankou_em.py +72 -34
- akshare/stock_feature/stock_report_em.py +244 -54
- akshare/stock_feature/stock_research_report_em.py +48 -19
- akshare/stock_feature/stock_sns_sseinfo.py +15 -12
- akshare/stock_feature/stock_sy_em.py +86 -33
- akshare/stock_feature/stock_technology_ths.py +152 -120
- akshare/stock_feature/stock_tfp_em.py +35 -13
- akshare/stock_feature/stock_three_report_em.py +119 -77
- akshare/stock_feature/stock_ttm_lyr.py +4 -7
- akshare/stock_feature/stock_value_em.py +83 -0
- akshare/stock_feature/stock_wencai.py +21 -9
- akshare/stock_feature/stock_yjyg_em.py +63 -28
- akshare/stock_feature/stock_zf_pg.py +61 -38
- akshare/stock_feature/stock_zh_valuation_baidu.py +3 -2
- akshare/stock_feature/stock_ztb_em.py +62 -40
- akshare/stock_fundamental/stock_finance.py +150 -58
- akshare/stock_fundamental/stock_finance_ths.py +116 -31
- akshare/stock_fundamental/stock_mda_ym.py +5 -3
- akshare/stock_fundamental/stock_notice.py +29 -15
- akshare/stock_fundamental/stock_profit_forecast_em.py +31 -13
- akshare/stock_fundamental/stock_profit_forecast_ths.py +19 -10
- akshare/stock_fundamental/stock_register_em.py +448 -0
- akshare/stock_fundamental/stock_restricted_em.py +79 -32
- akshare/stock_fundamental/stock_zygc.py +10 -8
- akshare/stock_fundamental/stock_zyjs_ths.py +5 -3
- akshare/tool/trade_date_hist.py +4 -3
- akshare/utils/cons.py +10 -0
- akshare/utils/context.py +43 -0
- akshare/utils/demjson.py +2 -2
- akshare/utils/func.py +26 -0
- akshare/utils/tqdm.py +13 -3
- {akshare-1.12.99.dist-info → akshare-1.15.73.dist-info}/METADATA +52 -69
- akshare-1.15.73.dist-info/RECORD +385 -0
- {akshare-1.12.99.dist-info → akshare-1.15.73.dist-info}/WHEEL +1 -1
- tests/test_func.py +3 -5
- akshare/bond/bond_futures.py +0 -50
- akshare/bond/bond_investing.py +0 -139
- akshare/crypto/crypto_hist_investing.py +0 -249
- akshare/fortune/fortune_it_juzi.py +0 -123
- akshare/futures/futures_international.py +0 -170
- akshare/futures/futures_news_baidu.py +0 -54
- akshare/futures/inventory_data.py +0 -100
- akshare/futures_derivative/futures_index_price_nh.py +0 -61
- akshare/futures_derivative/futures_index_return_nh.py +0 -47
- akshare/futures_derivative/futures_index_volatility_nh.py +0 -51
- akshare/futures_derivative/futures_other_index_nh.py +0 -145
- akshare/index/index_fear_greed_funddb.py +0 -71
- akshare/index/index_investing.py +0 -232
- akshare/sport/sport_olympic_winter.py +0 -39
- akshare/stock_feature/stock_board_concept_ths.py +0 -422
- akshare/stock_fundamental/stock_register.py +0 -292
- akshare-1.12.99.dist-info/RECORD +0 -374
- {akshare-1.12.99.dist-info → akshare-1.15.73.dist-info}/LICENSE +0 -0
- {akshare-1.12.99.dist-info → akshare-1.15.73.dist-info}/top_level.txt +0 -0
akshare/news/news_baidu.py
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
# -*- coding:utf-8 -*-
|
|
2
2
|
# !/usr/bin/env python
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/11/07 17:00
|
|
5
5
|
Desc: 百度股市通-经济数据
|
|
6
6
|
https://gushitong.baidu.com/calendar
|
|
7
7
|
"""
|
|
8
|
+
|
|
9
|
+
import http.client
|
|
10
|
+
import json
|
|
11
|
+
from urllib.parse import urlencode
|
|
12
|
+
|
|
8
13
|
import pandas as pd
|
|
9
|
-
import requests
|
|
10
14
|
|
|
11
15
|
|
|
12
|
-
def news_economic_baidu(date: str = "
|
|
16
|
+
def news_economic_baidu(date: str = "20241107") -> pd.DataFrame:
|
|
13
17
|
"""
|
|
14
18
|
百度股市通-经济数据
|
|
15
19
|
https://gushitong.baidu.com/calendar
|
|
@@ -20,17 +24,20 @@ def news_economic_baidu(date: str = "20220502") -> pd.DataFrame:
|
|
|
20
24
|
"""
|
|
21
25
|
start_date = "-".join([date[:4], date[4:6], date[6:]])
|
|
22
26
|
end_date = "-".join([date[:4], date[4:6], date[6:]])
|
|
23
|
-
|
|
27
|
+
conn = http.client.HTTPSConnection("finance.pae.baidu.com")
|
|
24
28
|
params = {
|
|
25
29
|
"start_date": start_date,
|
|
26
30
|
"end_date": end_date,
|
|
27
31
|
"market": "",
|
|
28
32
|
"cate": "economic_data",
|
|
29
|
-
"
|
|
30
|
-
"pn": "0",
|
|
33
|
+
"finClientType": "pc",
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
query_string = urlencode(params)
|
|
36
|
+
url = "/api/financecalendar" + "?" + query_string
|
|
37
|
+
conn.request(method="GET", url=url)
|
|
38
|
+
r = conn.getresponse()
|
|
39
|
+
data = r.read()
|
|
40
|
+
data_json = json.loads(data)
|
|
34
41
|
big_df = pd.DataFrame()
|
|
35
42
|
for item in data_json["Result"]:
|
|
36
43
|
if not item["list"] == []:
|
|
@@ -66,14 +73,13 @@ def news_economic_baidu(date: str = "20220502") -> pd.DataFrame:
|
|
|
66
73
|
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
|
|
67
74
|
temp_df["重要性"] = pd.to_numeric(temp_df["重要性"], errors="coerce")
|
|
68
75
|
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
69
|
-
|
|
70
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
76
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
71
77
|
else:
|
|
72
78
|
continue
|
|
73
79
|
return big_df
|
|
74
80
|
|
|
75
81
|
|
|
76
|
-
def news_trade_notify_suspend_baidu(date: str = "
|
|
82
|
+
def news_trade_notify_suspend_baidu(date: str = "20241107") -> pd.DataFrame:
|
|
77
83
|
"""
|
|
78
84
|
百度股市通-交易提醒-停复牌
|
|
79
85
|
https://gushitong.baidu.com/calendar
|
|
@@ -84,15 +90,20 @@ def news_trade_notify_suspend_baidu(date: str = "20220513") -> pd.DataFrame:
|
|
|
84
90
|
"""
|
|
85
91
|
start_date = "-".join([date[:4], date[4:6], date[6:]])
|
|
86
92
|
end_date = "-".join([date[:4], date[4:6], date[6:]])
|
|
87
|
-
|
|
93
|
+
conn = http.client.HTTPSConnection("finance.pae.baidu.com")
|
|
88
94
|
params = {
|
|
89
95
|
"start_date": start_date,
|
|
90
96
|
"end_date": end_date,
|
|
91
97
|
"market": "",
|
|
92
98
|
"cate": "notify_suspend",
|
|
99
|
+
"finClientType": "pc",
|
|
93
100
|
}
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
query_string = urlencode(params)
|
|
102
|
+
url = "/api/financecalendar" + "?" + query_string
|
|
103
|
+
conn.request(method="GET", url=url)
|
|
104
|
+
r = conn.getresponse()
|
|
105
|
+
data = r.read()
|
|
106
|
+
data_json = json.loads(data)
|
|
96
107
|
big_df = pd.DataFrame()
|
|
97
108
|
for item in data_json["Result"]:
|
|
98
109
|
if not item["list"] == []:
|
|
@@ -117,15 +128,19 @@ def news_trade_notify_suspend_baidu(date: str = "20220513") -> pd.DataFrame:
|
|
|
117
128
|
"停牌事项说明",
|
|
118
129
|
]
|
|
119
130
|
]
|
|
120
|
-
temp_df["停牌时间"] = pd.to_datetime(
|
|
121
|
-
|
|
131
|
+
temp_df["停牌时间"] = pd.to_datetime(
|
|
132
|
+
temp_df["停牌时间"], errors="coerce"
|
|
133
|
+
).dt.date
|
|
134
|
+
temp_df["复牌时间"] = pd.to_datetime(
|
|
135
|
+
temp_df["复牌时间"], errors="coerce"
|
|
136
|
+
).dt.date
|
|
122
137
|
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
123
138
|
else:
|
|
124
139
|
continue
|
|
125
140
|
return big_df
|
|
126
141
|
|
|
127
142
|
|
|
128
|
-
def news_trade_notify_dividend_baidu(date: str = "
|
|
143
|
+
def news_trade_notify_dividend_baidu(date: str = "20241107") -> pd.DataFrame:
|
|
129
144
|
"""
|
|
130
145
|
百度股市通-交易提醒-分红派息
|
|
131
146
|
https://gushitong.baidu.com/calendar
|
|
@@ -136,31 +151,42 @@ def news_trade_notify_dividend_baidu(date: str = "20220916") -> pd.DataFrame:
|
|
|
136
151
|
"""
|
|
137
152
|
start_date = "-".join([date[:4], date[4:6], date[6:]])
|
|
138
153
|
end_date = "-".join([date[:4], date[4:6], date[6:]])
|
|
139
|
-
|
|
154
|
+
conn = http.client.HTTPSConnection("finance.pae.baidu.com")
|
|
140
155
|
params = {
|
|
141
156
|
"start_date": start_date,
|
|
142
157
|
"end_date": end_date,
|
|
143
158
|
"market": "",
|
|
144
159
|
"cate": "notify_divide",
|
|
160
|
+
"rn": 500,
|
|
161
|
+
"pn": 0,
|
|
145
162
|
}
|
|
146
|
-
|
|
147
|
-
|
|
163
|
+
query_string = urlencode(params)
|
|
164
|
+
url = "/api/financecalendar" + "?" + query_string
|
|
165
|
+
conn.request(method="GET", url=url)
|
|
166
|
+
r = conn.getresponse()
|
|
167
|
+
data = r.read()
|
|
168
|
+
data_json = json.loads(data)
|
|
148
169
|
big_df = pd.DataFrame()
|
|
149
170
|
for item in data_json["Result"]:
|
|
150
171
|
if not item["list"] == []:
|
|
151
172
|
temp_df = pd.DataFrame(item["list"])
|
|
152
|
-
temp_df.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
173
|
+
temp_df.rename(
|
|
174
|
+
columns={
|
|
175
|
+
"code": "股票代码",
|
|
176
|
+
"market": "-",
|
|
177
|
+
"exchange": "交易所",
|
|
178
|
+
"name": "股票简称",
|
|
179
|
+
"diviDate": "除权日",
|
|
180
|
+
"date": "报告期",
|
|
181
|
+
"diviCash": "分红",
|
|
182
|
+
"shareDivide": "送股",
|
|
183
|
+
"transfer": "转增",
|
|
184
|
+
"physical": "实物",
|
|
185
|
+
},
|
|
186
|
+
inplace=True,
|
|
187
|
+
)
|
|
188
|
+
if "实物" not in temp_df.columns:
|
|
189
|
+
temp_df["实物"] = pd.NA
|
|
164
190
|
temp_df = temp_df[
|
|
165
191
|
[
|
|
166
192
|
"股票代码",
|
|
@@ -174,15 +200,19 @@ def news_trade_notify_dividend_baidu(date: str = "20220916") -> pd.DataFrame:
|
|
|
174
200
|
"报告期",
|
|
175
201
|
]
|
|
176
202
|
]
|
|
177
|
-
temp_df["除权日"] = pd.to_datetime(
|
|
178
|
-
|
|
179
|
-
|
|
203
|
+
temp_df["除权日"] = pd.to_datetime(
|
|
204
|
+
temp_df["除权日"], errors="coerce"
|
|
205
|
+
).dt.date
|
|
206
|
+
temp_df["报告期"] = pd.to_datetime(
|
|
207
|
+
temp_df["报告期"], errors="coerce"
|
|
208
|
+
).dt.date
|
|
209
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
180
210
|
else:
|
|
181
211
|
continue
|
|
182
212
|
return big_df
|
|
183
213
|
|
|
184
214
|
|
|
185
|
-
def news_report_time_baidu(date: str = "
|
|
215
|
+
def news_report_time_baidu(date: str = "20241107") -> pd.DataFrame:
|
|
186
216
|
"""
|
|
187
217
|
百度股市通-财报发行
|
|
188
218
|
https://gushitong.baidu.com/calendar
|
|
@@ -193,7 +223,7 @@ def news_report_time_baidu(date: str = "20220514") -> pd.DataFrame:
|
|
|
193
223
|
"""
|
|
194
224
|
start_date = "-".join([date[:4], date[4:6], date[6:]])
|
|
195
225
|
end_date = "-".join([date[:4], date[4:6], date[6:]])
|
|
196
|
-
|
|
226
|
+
conn = http.client.HTTPSConnection("finance.pae.baidu.com")
|
|
197
227
|
params = {
|
|
198
228
|
"start_date": start_date,
|
|
199
229
|
"end_date": end_date,
|
|
@@ -201,8 +231,12 @@ def news_report_time_baidu(date: str = "20220514") -> pd.DataFrame:
|
|
|
201
231
|
"cate": "report_time",
|
|
202
232
|
"finClientType": "pc",
|
|
203
233
|
}
|
|
204
|
-
|
|
205
|
-
|
|
234
|
+
query_string = urlencode(params)
|
|
235
|
+
url = "/api/financecalendar" + "?" + query_string
|
|
236
|
+
conn.request(method="GET", url=url)
|
|
237
|
+
r = conn.getresponse()
|
|
238
|
+
data = r.read()
|
|
239
|
+
data_json = json.loads(data)
|
|
206
240
|
big_df = pd.DataFrame()
|
|
207
241
|
for item in data_json["Result"]:
|
|
208
242
|
if not item["list"] == []:
|
|
@@ -224,25 +258,25 @@ def news_report_time_baidu(date: str = "20220514") -> pd.DataFrame:
|
|
|
224
258
|
"财报期",
|
|
225
259
|
]
|
|
226
260
|
]
|
|
227
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
261
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
228
262
|
else:
|
|
229
263
|
continue
|
|
230
264
|
return big_df
|
|
231
265
|
|
|
232
266
|
|
|
233
267
|
if __name__ == "__main__":
|
|
234
|
-
news_economic_baidu_df = news_economic_baidu(date="
|
|
268
|
+
news_economic_baidu_df = news_economic_baidu(date="20241107")
|
|
235
269
|
print(news_economic_baidu_df)
|
|
236
270
|
|
|
237
271
|
news_trade_notify_suspend_baidu_df = news_trade_notify_suspend_baidu(
|
|
238
|
-
date="
|
|
272
|
+
date="20241107"
|
|
239
273
|
)
|
|
240
274
|
print(news_trade_notify_suspend_baidu_df)
|
|
241
275
|
|
|
242
276
|
news_trade_notify_dividend_baidu_df = news_trade_notify_dividend_baidu(
|
|
243
|
-
date="
|
|
277
|
+
date="20241107"
|
|
244
278
|
)
|
|
245
279
|
print(news_trade_notify_dividend_baidu_df)
|
|
246
280
|
|
|
247
|
-
news_report_time_baidu_df = news_report_time_baidu(date="
|
|
281
|
+
news_report_time_baidu_df = news_report_time_baidu(date="20241107")
|
|
248
282
|
print(news_report_time_baidu_df)
|
akshare/news/news_cctv.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/4/25 17:00
|
|
5
5
|
Desc: 新闻联播文字稿
|
|
6
|
-
https://tv.cctv.com/lm/xwlb
|
|
6
|
+
https://tv.cctv.com/lm/xwlb
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import re
|
|
9
10
|
|
|
10
11
|
import pandas as pd
|
|
@@ -13,28 +14,28 @@ from bs4 import BeautifulSoup
|
|
|
13
14
|
from tqdm import tqdm
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
def news_cctv(date: str = "
|
|
17
|
+
def news_cctv(date: str = "20240424") -> pd.DataFrame:
|
|
17
18
|
"""
|
|
18
19
|
新闻联播文字稿
|
|
19
|
-
https://tv.cctv.com/lm/xwlb
|
|
20
|
+
https://tv.cctv.com/lm/xwlb
|
|
20
21
|
:param date: 需要获取数据的日期; 目前 20160203 年后
|
|
21
22
|
:type date: str
|
|
22
23
|
:return: 新闻联播文字稿
|
|
23
24
|
:rtype: pandas.DataFrame
|
|
24
25
|
"""
|
|
25
26
|
if int(date) <= int("20130708"):
|
|
26
|
-
url = f"
|
|
27
|
+
url = f"https://cctv.cntv.cn/lm/xinwenlianbo/{date}.shtml"
|
|
27
28
|
r = requests.get(url)
|
|
28
29
|
r.encoding = "gbk"
|
|
29
30
|
raw_list = re.findall(r"title_array_01\((.*)", r.text)
|
|
30
31
|
page_url = [
|
|
31
|
-
re.findall("(http.*)", item)[0].split("'")[0]
|
|
32
|
-
for item in raw_list[1:]
|
|
32
|
+
re.findall("(http.*)", item)[0].split("'")[0] for item in raw_list[1:]
|
|
33
33
|
]
|
|
34
34
|
title_list = []
|
|
35
35
|
content_list = []
|
|
36
36
|
headers = {
|
|
37
|
-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,
|
|
37
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,"
|
|
38
|
+
"image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
|
38
39
|
"Accept-Encoding": "gzip, deflate",
|
|
39
40
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
|
40
41
|
"Cache-Control": "no-cache",
|
|
@@ -43,7 +44,8 @@ def news_cctv(date: str = "20130308") -> pd.DataFrame:
|
|
|
43
44
|
"Pragma": "no-cache",
|
|
44
45
|
"Proxy-Connection": "keep-alive",
|
|
45
46
|
"Upgrade-Insecure-Requests": "1",
|
|
46
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
47
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
48
|
+
"Chrome/92.0.4515.159 Safari/537.36",
|
|
47
49
|
}
|
|
48
50
|
for page in tqdm(page_url, leave=False):
|
|
49
51
|
try:
|
|
@@ -52,9 +54,7 @@ def news_cctv(date: str = "20130308") -> pd.DataFrame:
|
|
|
52
54
|
soup = BeautifulSoup(r.text, "lxml")
|
|
53
55
|
title = soup.find("h3").text
|
|
54
56
|
content = soup.find("div", attrs={"class": "cnt_bd"}).text
|
|
55
|
-
title_list.append(
|
|
56
|
-
title.strip("[视频]").strip().replace("\n", " ")
|
|
57
|
-
)
|
|
57
|
+
title_list.append(title.strip("[视频]").strip().replace("\n", " "))
|
|
58
58
|
content_list.append(
|
|
59
59
|
content.strip()
|
|
60
60
|
.strip("央视网消息(新闻联播):")
|
|
@@ -63,29 +63,30 @@ def news_cctv(date: str = "20130308") -> pd.DataFrame:
|
|
|
63
63
|
.strip()
|
|
64
64
|
.replace("\n", " ")
|
|
65
65
|
)
|
|
66
|
-
except:
|
|
66
|
+
except: # noqa: E722
|
|
67
67
|
continue
|
|
68
68
|
temp_df = pd.DataFrame(
|
|
69
|
-
[[date] * len(title_list), title_list, content_list],
|
|
69
|
+
data=[[date] * len(title_list), title_list, content_list],
|
|
70
70
|
index=["date", "title", "content"],
|
|
71
71
|
).T
|
|
72
72
|
return temp_df
|
|
73
73
|
|
|
74
74
|
elif int(date) < int("20160203"):
|
|
75
|
-
url = f"
|
|
75
|
+
url = f"https://cctv.cntv.cn/lm/xinwenlianbo/{date}.shtml"
|
|
76
76
|
r = requests.get(url)
|
|
77
77
|
r.encoding = "utf-8"
|
|
78
78
|
soup = BeautifulSoup(r.text, "lxml")
|
|
79
79
|
page_url = [
|
|
80
80
|
item.find("a")["href"]
|
|
81
81
|
for item in soup.find(
|
|
82
|
-
"div", attrs={"id": "contentELMT1368521805488378"}
|
|
82
|
+
name="div", attrs={"id": "contentELMT1368521805488378"}
|
|
83
83
|
).find_all("li")[1:]
|
|
84
84
|
]
|
|
85
85
|
title_list = []
|
|
86
86
|
content_list = []
|
|
87
87
|
headers = {
|
|
88
|
-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,
|
|
88
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,"
|
|
89
|
+
"image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
|
89
90
|
"Accept-Encoding": "gzip, deflate",
|
|
90
91
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
|
91
92
|
"Cache-Control": "no-cache",
|
|
@@ -94,18 +95,17 @@ def news_cctv(date: str = "20130308") -> pd.DataFrame:
|
|
|
94
95
|
"Pragma": "no-cache",
|
|
95
96
|
"Proxy-Connection": "keep-alive",
|
|
96
97
|
"Upgrade-Insecure-Requests": "1",
|
|
97
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
98
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
99
|
+
"Chrome/92.0.4515.159 Safari/537.36",
|
|
98
100
|
}
|
|
99
101
|
for page in tqdm(page_url, leave=False):
|
|
100
102
|
try:
|
|
101
103
|
r = requests.get(page, headers=headers)
|
|
102
104
|
r.encoding = "utf-8"
|
|
103
|
-
soup = BeautifulSoup(r.text, "lxml")
|
|
105
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
104
106
|
title = soup.find("h3").text
|
|
105
|
-
content = soup.find("div", attrs={"class": "cnt_bd"}).text
|
|
106
|
-
title_list.append(
|
|
107
|
-
title.strip("[视频]").strip().replace("\n", " ")
|
|
108
|
-
)
|
|
107
|
+
content = soup.find(name="div", attrs={"class": "cnt_bd"}).text
|
|
108
|
+
title_list.append(title.strip("[视频]").strip().replace("\n", " "))
|
|
109
109
|
content_list.append(
|
|
110
110
|
content.strip()
|
|
111
111
|
.strip("央视网消息(新闻联播):")
|
|
@@ -114,10 +114,10 @@ def news_cctv(date: str = "20130308") -> pd.DataFrame:
|
|
|
114
114
|
.strip()
|
|
115
115
|
.replace("\n", " ")
|
|
116
116
|
)
|
|
117
|
-
except:
|
|
117
|
+
except: # noqa: E722
|
|
118
118
|
continue
|
|
119
119
|
temp_df = pd.DataFrame(
|
|
120
|
-
[[date] * len(title_list), title_list, content_list],
|
|
120
|
+
data=[[date] * len(title_list), title_list, content_list],
|
|
121
121
|
index=["date", "title", "content"],
|
|
122
122
|
).T
|
|
123
123
|
return temp_df
|
|
@@ -130,7 +130,8 @@ def news_cctv(date: str = "20130308") -> pd.DataFrame:
|
|
|
130
130
|
title_list = []
|
|
131
131
|
content_list = []
|
|
132
132
|
headers = {
|
|
133
|
-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,
|
|
133
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,"
|
|
134
|
+
"image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
|
134
135
|
"Accept-Encoding": "gzip, deflate",
|
|
135
136
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
|
136
137
|
"Cache-Control": "no-cache",
|
|
@@ -139,26 +140,25 @@ def news_cctv(date: str = "20130308") -> pd.DataFrame:
|
|
|
139
140
|
"Pragma": "no-cache",
|
|
140
141
|
"Proxy-Connection": "keep-alive",
|
|
141
142
|
"Upgrade-Insecure-Requests": "1",
|
|
142
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
143
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
144
|
+
"Chrome/92.0.4515.159 Safari/537.36",
|
|
143
145
|
}
|
|
144
146
|
for page in tqdm(page_url, leave=False):
|
|
145
147
|
try:
|
|
146
148
|
r = requests.get(page, headers=headers)
|
|
147
149
|
r.encoding = "utf-8"
|
|
148
|
-
soup = BeautifulSoup(r.text, "lxml")
|
|
150
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
149
151
|
if soup.find("h3"):
|
|
150
152
|
title = soup.find("h3").text
|
|
151
153
|
else:
|
|
152
|
-
title = soup.find("div", attrs={"class": "tit"}).text
|
|
153
|
-
if soup.find("div", attrs={"class": "cnt_bd"}):
|
|
154
|
-
content = soup.find("div", attrs={"class": "cnt_bd"}).text
|
|
154
|
+
title = soup.find(name="div", attrs={"class": "tit"}).text
|
|
155
|
+
if soup.find(name="div", attrs={"class": "cnt_bd"}):
|
|
156
|
+
content = soup.find(name="div", attrs={"class": "cnt_bd"}).text
|
|
155
157
|
else:
|
|
156
158
|
content = soup.find(
|
|
157
|
-
"div", attrs={"class": "content_area"}
|
|
159
|
+
name="div", attrs={"class": "content_area"}
|
|
158
160
|
).text
|
|
159
|
-
title_list.append(
|
|
160
|
-
title.strip("[视频]").strip().replace("\n", " ")
|
|
161
|
-
)
|
|
161
|
+
title_list.append(title.strip("[视频]").strip().replace("\n", " "))
|
|
162
162
|
content_list.append(
|
|
163
163
|
content.strip()
|
|
164
164
|
.strip("央视网消息(新闻联播):")
|
|
@@ -167,15 +167,15 @@ def news_cctv(date: str = "20130308") -> pd.DataFrame:
|
|
|
167
167
|
.strip()
|
|
168
168
|
.replace("\n", " ")
|
|
169
169
|
)
|
|
170
|
-
except:
|
|
170
|
+
except: # noqa: E722
|
|
171
171
|
continue
|
|
172
172
|
temp_df = pd.DataFrame(
|
|
173
|
-
[[date] * len(title_list), title_list, content_list],
|
|
173
|
+
data=[[date] * len(title_list), title_list, content_list],
|
|
174
174
|
index=["date", "title", "content"],
|
|
175
175
|
).T
|
|
176
176
|
return temp_df
|
|
177
177
|
|
|
178
178
|
|
|
179
179
|
if __name__ == "__main__":
|
|
180
|
-
news_cctv_df = news_cctv(date="
|
|
180
|
+
news_cctv_df = news_cctv(date="20240424")
|
|
181
181
|
print(news_cctv_df)
|
akshare/news/news_stock.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/05/23 14:00
|
|
5
5
|
Desc: 个股新闻数据
|
|
6
6
|
https://so.eastmoney.com/news/s?keyword=%E4%B8%AD%E5%9B%BD%E4%BA%BA%E5%AF%BF&pageindex=1&searchrange=8192&sortfiled=4
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import json
|
|
9
10
|
|
|
10
11
|
import pandas as pd
|
|
@@ -20,12 +21,14 @@ def stock_news_em(symbol: str = "300059") -> pd.DataFrame:
|
|
|
20
21
|
:return: 个股新闻
|
|
21
22
|
:rtype: pandas.DataFrame
|
|
22
23
|
"""
|
|
23
|
-
url = "
|
|
24
|
+
url = "http://search-api-web.eastmoney.com/search/jsonp"
|
|
24
25
|
params = {
|
|
25
26
|
"cb": "jQuery3510875346244069884_1668256937995",
|
|
26
27
|
"param": '{"uid":"",'
|
|
27
28
|
+ f'"keyword":"{symbol}"'
|
|
28
|
-
+ ',"type":["cmsArticleWebOld"],"client":"web","clientType":"web","clientVersion":"curr",
|
|
29
|
+
+ ',"type":["cmsArticleWebOld"],"client":"web","clientType":"web","clientVersion":"curr",'
|
|
30
|
+
'"param":{"cmsArticleWebOld":{"searchScope":"default","sort":"default","pageIndex":1,'
|
|
31
|
+
'"pageSize":100,"preTag":"<em>","postTag":"</em>"}}}',
|
|
29
32
|
"_": "1668256937996",
|
|
30
33
|
}
|
|
31
34
|
r = requests.get(url, params=params)
|
akshare/nlp/nlp_interface.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/7/6 14:02
|
|
5
5
|
Desc: ownthink-knowledge graph
|
|
6
6
|
https://ownthink.com/
|
|
7
7
|
https://www.ownthink.com/docs/kg/
|
|
8
8
|
"""
|
|
9
|
+
|
|
9
10
|
import pandas as pd
|
|
10
11
|
import requests
|
|
11
12
|
|
|
@@ -28,7 +29,7 @@ def nlp_ownthink(word: str = "人工智能", indicator: str = "entity") -> pd.Da
|
|
|
28
29
|
r = requests.post(url, data=payload)
|
|
29
30
|
if not r.json()["data"]:
|
|
30
31
|
print("Can not find the resource, please type into the correct word")
|
|
31
|
-
return
|
|
32
|
+
return pd.DataFrame()
|
|
32
33
|
if indicator == "entity":
|
|
33
34
|
return r.json()["data"]["entity"]
|
|
34
35
|
if indicator == "desc":
|
|
@@ -48,18 +49,16 @@ def nlp_answer(question: str = "人工智能") -> str:
|
|
|
48
49
|
:return: indicator data
|
|
49
50
|
:rtype: list or dict or pandas.DataFrame
|
|
50
51
|
"""
|
|
51
|
-
url =
|
|
52
|
-
params = {
|
|
53
|
-
'spoken': question
|
|
54
|
-
}
|
|
52
|
+
url = "https://api.ownthink.com/bot"
|
|
53
|
+
params = {"spoken": question}
|
|
55
54
|
r = requests.get(url, params=params)
|
|
56
55
|
json_data = r.json()
|
|
57
|
-
answer = json_data[
|
|
56
|
+
answer = json_data["data"]["info"]["text"]
|
|
58
57
|
return answer
|
|
59
58
|
|
|
60
59
|
|
|
61
60
|
if __name__ == "__main__":
|
|
62
|
-
nlp_ownthink_df = nlp_ownthink(word="人工智能", indicator="
|
|
61
|
+
nlp_ownthink_df = nlp_ownthink(word="人工智能", indicator="entity")
|
|
63
62
|
print(nlp_ownthink_df)
|
|
64
63
|
|
|
65
64
|
nlp_answer_df = nlp_answer(question="姚明的身高")
|
akshare/option/cons.py
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Date: 2019/9/30 13:58
|
|
5
5
|
Desc: 期权配置文件
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
import datetime
|
|
8
9
|
import json
|
|
9
10
|
import os
|
|
@@ -38,21 +39,22 @@ SH_OPTION_PAYLOAD = {
|
|
|
38
39
|
"select": "select: code,name,last,change,chg_rate,amp_rate,volume,amount,prev_close"
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
SH_OPTION_PAYLOAD_OTHER = {
|
|
42
|
-
"select": "contractid,last,chg_rate,presetpx,exepx"
|
|
43
|
-
}
|
|
44
|
-
|
|
42
|
+
SH_OPTION_PAYLOAD_OTHER = {"select": "contractid,last,chg_rate,presetpx,exepx"}
|
|
45
43
|
|
|
46
44
|
|
|
47
45
|
# 大连商品交易所
|
|
48
46
|
DCE_OPTION_URL = "http://www.dce.com.cn/publicweb/quotesdata/dayQuotesCh.html"
|
|
49
|
-
DCE_DAILY_OPTION_URL =
|
|
47
|
+
DCE_DAILY_OPTION_URL = (
|
|
48
|
+
"http://www.dce.com.cn/publicweb/quotesdata/exportDayQuotesChData.html"
|
|
49
|
+
)
|
|
50
50
|
|
|
51
51
|
# 上海期货交易所
|
|
52
|
-
SHFE_OPTION_URL = "
|
|
52
|
+
SHFE_OPTION_URL = "https://tsite.shfe.com.cn/data/dailydata/option/kx/kx{}.dat"
|
|
53
53
|
|
|
54
54
|
# 郑州商品交易所
|
|
55
|
-
CZCE_DAILY_OPTION_URL_3 =
|
|
55
|
+
CZCE_DAILY_OPTION_URL_3 = (
|
|
56
|
+
"http://www.czce.com.cn/cn/DFSStaticFiles/Option/{}/{}/OptionDataDaily.txt"
|
|
57
|
+
)
|
|
56
58
|
|
|
57
59
|
# PAYLOAD
|
|
58
60
|
SHFE_HEADERS = {"User-Agent": "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"}
|
|
@@ -74,10 +76,8 @@ def convert_date(date):
|
|
|
74
76
|
groups = match.groups()
|
|
75
77
|
if len(groups) == 3:
|
|
76
78
|
return datetime.date(
|
|
77
|
-
year=int(
|
|
78
|
-
|
|
79
|
-
groups[1]), day=int(
|
|
80
|
-
groups[2]))
|
|
79
|
+
year=int(groups[0]), month=int(groups[1]), day=int(groups[2])
|
|
80
|
+
)
|
|
81
81
|
return None
|
|
82
82
|
|
|
83
83
|
|