akshare-proxy-patch 0.2.13__tar.gz → 0.3.0__tar.gz

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-proxy-patch might be problematic. Click here for more details.

@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: akshare-proxy-patch
3
+ Version: 0.3.0
4
+ Summary: 针对 AkShare 和 efinance 的底层补丁,自动为东财等接口注入代理认证头,从而避免 `stock_zh_a_spot_em` 等方法报错。
5
+ Home-page: https://github.com/helloyie/akshare-proxy-patch
6
+ Author: cheapproxy.net
7
+ Author-email: cheapproxy <emezxyj1@gmail.com>
8
+ Project-URL: Homepage, https://github.com/helloyie/akshare-proxy-patch
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: requests
16
+ Requires-Dist: curl_cffi
17
+ Dynamic: author
18
+ Dynamic: home-page
19
+ Dynamic: license-file
20
+ Dynamic: requires-python
21
+
22
+ # AkShare Proxy Patch
23
+
24
+ > 针对 [AKShare](https://github.com/akfamily/akshare)、[efinance](https://github.com/Micro-sheep/efinance)、[yfinance](https://github.com/ranaroussi/yfinance) 的🐒插件补丁,自动为函数注入请求头,解决 `stock_zh_a_spot_em`、`stock_zh_a_hist`、`get_realtime_quotes` 等东财接口报错问题和 Yahoo `YFRateLimitError` 问题。
25
+
26
+ ## ✨ 特性
27
+
28
+ - `AKShare` 东财接口报错问题
29
+ - `efinance` 东财接口报错问题
30
+ - `yfinance` Yahoo接口报错问题
31
+
32
+ ## 📦 安装
33
+
34
+ 1. 安装并升级官方 [akshare](https://github.com/akfamily/akshare) 或 [efinance](https://github.com/Micro-sheep/efinance) 包
35
+
36
+ 2. 安装 `akshare-proxy-patch` 插件
37
+
38
+ ```
39
+ pip install akshare-proxy-patch==0.3.0
40
+ ```
41
+
42
+ ## 🚀 使用方法(akshare / efinance / yfinance)
43
+
44
+ 1. [点击前往插件官网](https://ak.cheapproxy.net/dashboard/akshare) 获取 `TOKEN`。
45
+
46
+ 2. `akshare` 和 `efinance` 集成:在 Python 文件顶部添加如下代码,并替换 `你的TOKEN`。
47
+
48
+ ```
49
+ # python 文件顶部添加如下代码
50
+ import akshare_proxy_patch
51
+
52
+ akshare_proxy_patch.install_patch(
53
+ "101.201.173.125",
54
+ auth_token="你的TOKEN",
55
+ retry=30,
56
+ # 封控的域名列表,可自行调整
57
+ hook_domains=[
58
+ "fund.eastmoney.com",
59
+ "push2.eastmoney.com",
60
+ "push2his.eastmoney.com",
61
+ "emweb.securities.eastmoney.com",
62
+ ],
63
+ )
64
+
65
+ # --------------------------
66
+ # 后续你的正常业务代码保持不变
67
+ # --------------------------
68
+
69
+ # 假如你使用 akshare
70
+ import akshare as ak
71
+ df = ak.stock_zh_a_spot_em()
72
+
73
+ # 假如你使用 efinance
74
+ import efinance as ef
75
+ ef.stock.get_realtime_quotes()
76
+ ```
77
+
78
+ 3. `yfinance` 集成:在 Python 文件顶部添加如下代码,并替换 `你的TOKEN`。
79
+
80
+ ```
81
+ # python 文件顶部添加如下代码
82
+ import akshare_proxy_patch
83
+
84
+ akshare_proxy_patch.install_yfinance_patch(
85
+ "101.201.173.125",
86
+ auth_token="你的TOKEN",
87
+ retry=30,
88
+ )
89
+
90
+ # --------------------------
91
+ # 后续你的正常业务代码保持不变
92
+ # --------------------------
93
+
94
+ import yfinance as yf
95
+
96
+ data = yf.download("AAPL", start="2017-01-01", end="2017-04-30")
97
+ ```
98
+
99
+ ## 📖 install_patch 参数说明
100
+
101
+ - 参数1:网关
102
+ - 默认为 `101.201.173.125` 不可修改
103
+ - 参数2:TOKEN
104
+ - 授权凭证
105
+ - 参数3:重试次数
106
+ - 默认为30,建议保持不变
107
+ - 参数4:封控的域名列表
108
+ - 接口 `URL` 包含数组中的其中一条,就会走插件。
109
+ - 可点击 `ak` 或 `ef` 函数查看接口源码对应的 `URL`,根据封控情况细化可以降低积分消耗。
110
+ - 如只封控 `stock_zh_a_spot_em` 这个接口,`hook_domains` 可设置为 `["https://82.push2.eastmoney.com/api/qt/clist/get"]`。
111
+
112
+ ## 🛠️ 如何在 aktools 内集成插件?
113
+
114
+ `aktools` 想要集成插件,需要新建一个 `akt.py` 替换官方的 `python -m aktools` 启动命令,下面是 `akt.py` 内容:
115
+
116
+ ```
117
+ # 添加插件
118
+ import akshare_proxy_patch
119
+
120
+ akshare_proxy_patch.install_patch(
121
+ "101.201.173.125",
122
+ auth_token="你的TOKEN",
123
+ retry=30,
124
+ # 封控的域名列表,可自行调整
125
+ hook_domains=[
126
+ "fund.eastmoney.com",
127
+ "push2.eastmoney.com",
128
+ "push2his.eastmoney.com",
129
+ "emweb.securities.eastmoney.com",
130
+ ],
131
+ )
132
+
133
+ # 启动 aktools
134
+ import uvicorn
135
+
136
+ if __name__ == '__main__':
137
+ uvicorn.run(
138
+ "aktools.main:app",
139
+ host="0.0.0.0",
140
+ port=8080,
141
+ reload=False,
142
+ # 根据 CPU 核心数调整,推荐 2×核心数 + 1
143
+ workers=4,
144
+ log_level="info"
145
+ )
146
+ ```
147
+
148
+ 然后执行 `python akt.py` 即可启动一个 `http://127.0.0.1:8080/` 服务。只是启动方式不同而已,使用请参考 [aktools 官方文档](https://github.com/akfamily/aktools)。
149
+
150
+ ## ❓ 我没使用 akshare 或 efinance,能集成插件吗?
151
+
152
+ - 如果使用 Python 语言的 `requests` 库请求东财接口,插件能自动 hook 住请求,正常工作。
153
+ - 如果您使用其他语言或 python 的其他库,可 [手动提取代理](http://101.201.173.125:47001/api/akshare-auth?token=&version=0.2.13) 自行实现封控解除。
154
+
155
+ ## 💬 使用问题交流群
156
+
157
+ 如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
158
+
159
+ ![TVsbhbIuCF9Ga1Fwe3L2BX3s8UMauTAL.webp](https://cdn.nodeimage.com/i/TVsbhbIuCF9Ga1Fwe3L2BX3s8UMauTAL.webp)
@@ -0,0 +1,138 @@
1
+ # AkShare Proxy Patch
2
+
3
+ > 针对 [AKShare](https://github.com/akfamily/akshare)、[efinance](https://github.com/Micro-sheep/efinance)、[yfinance](https://github.com/ranaroussi/yfinance) 的🐒插件补丁,自动为函数注入请求头,解决 `stock_zh_a_spot_em`、`stock_zh_a_hist`、`get_realtime_quotes` 等东财接口报错问题和 Yahoo `YFRateLimitError` 问题。
4
+
5
+ ## ✨ 特性
6
+
7
+ - `AKShare` 东财接口报错问题
8
+ - `efinance` 东财接口报错问题
9
+ - `yfinance` Yahoo接口报错问题
10
+
11
+ ## 📦 安装
12
+
13
+ 1. 安装并升级官方 [akshare](https://github.com/akfamily/akshare) 或 [efinance](https://github.com/Micro-sheep/efinance) 包
14
+
15
+ 2. 安装 `akshare-proxy-patch` 插件
16
+
17
+ ```
18
+ pip install akshare-proxy-patch==0.3.0
19
+ ```
20
+
21
+ ## 🚀 使用方法(akshare / efinance / yfinance)
22
+
23
+ 1. [点击前往插件官网](https://ak.cheapproxy.net/dashboard/akshare) 获取 `TOKEN`。
24
+
25
+ 2. `akshare` 和 `efinance` 集成:在 Python 文件顶部添加如下代码,并替换 `你的TOKEN`。
26
+
27
+ ```
28
+ # python 文件顶部添加如下代码
29
+ import akshare_proxy_patch
30
+
31
+ akshare_proxy_patch.install_patch(
32
+ "101.201.173.125",
33
+ auth_token="你的TOKEN",
34
+ retry=30,
35
+ # 封控的域名列表,可自行调整
36
+ hook_domains=[
37
+ "fund.eastmoney.com",
38
+ "push2.eastmoney.com",
39
+ "push2his.eastmoney.com",
40
+ "emweb.securities.eastmoney.com",
41
+ ],
42
+ )
43
+
44
+ # --------------------------
45
+ # 后续你的正常业务代码保持不变
46
+ # --------------------------
47
+
48
+ # 假如你使用 akshare
49
+ import akshare as ak
50
+ df = ak.stock_zh_a_spot_em()
51
+
52
+ # 假如你使用 efinance
53
+ import efinance as ef
54
+ ef.stock.get_realtime_quotes()
55
+ ```
56
+
57
+ 3. `yfinance` 集成:在 Python 文件顶部添加如下代码,并替换 `你的TOKEN`。
58
+
59
+ ```
60
+ # python 文件顶部添加如下代码
61
+ import akshare_proxy_patch
62
+
63
+ akshare_proxy_patch.install_yfinance_patch(
64
+ "101.201.173.125",
65
+ auth_token="你的TOKEN",
66
+ retry=30,
67
+ )
68
+
69
+ # --------------------------
70
+ # 后续你的正常业务代码保持不变
71
+ # --------------------------
72
+
73
+ import yfinance as yf
74
+
75
+ data = yf.download("AAPL", start="2017-01-01", end="2017-04-30")
76
+ ```
77
+
78
+ ## 📖 install_patch 参数说明
79
+
80
+ - 参数1:网关
81
+ - 默认为 `101.201.173.125` 不可修改
82
+ - 参数2:TOKEN
83
+ - 授权凭证
84
+ - 参数3:重试次数
85
+ - 默认为30,建议保持不变
86
+ - 参数4:封控的域名列表
87
+ - 接口 `URL` 包含数组中的其中一条,就会走插件。
88
+ - 可点击 `ak` 或 `ef` 函数查看接口源码对应的 `URL`,根据封控情况细化可以降低积分消耗。
89
+ - 如只封控 `stock_zh_a_spot_em` 这个接口,`hook_domains` 可设置为 `["https://82.push2.eastmoney.com/api/qt/clist/get"]`。
90
+
91
+ ## 🛠️ 如何在 aktools 内集成插件?
92
+
93
+ `aktools` 想要集成插件,需要新建一个 `akt.py` 替换官方的 `python -m aktools` 启动命令,下面是 `akt.py` 内容:
94
+
95
+ ```
96
+ # 添加插件
97
+ import akshare_proxy_patch
98
+
99
+ akshare_proxy_patch.install_patch(
100
+ "101.201.173.125",
101
+ auth_token="你的TOKEN",
102
+ retry=30,
103
+ # 封控的域名列表,可自行调整
104
+ hook_domains=[
105
+ "fund.eastmoney.com",
106
+ "push2.eastmoney.com",
107
+ "push2his.eastmoney.com",
108
+ "emweb.securities.eastmoney.com",
109
+ ],
110
+ )
111
+
112
+ # 启动 aktools
113
+ import uvicorn
114
+
115
+ if __name__ == '__main__':
116
+ uvicorn.run(
117
+ "aktools.main:app",
118
+ host="0.0.0.0",
119
+ port=8080,
120
+ reload=False,
121
+ # 根据 CPU 核心数调整,推荐 2×核心数 + 1
122
+ workers=4,
123
+ log_level="info"
124
+ )
125
+ ```
126
+
127
+ 然后执行 `python akt.py` 即可启动一个 `http://127.0.0.1:8080/` 服务。只是启动方式不同而已,使用请参考 [aktools 官方文档](https://github.com/akfamily/aktools)。
128
+
129
+ ## ❓ 我没使用 akshare 或 efinance,能集成插件吗?
130
+
131
+ - 如果使用 Python 语言的 `requests` 库请求东财接口,插件能自动 hook 住请求,正常工作。
132
+ - 如果您使用其他语言或 python 的其他库,可 [手动提取代理](http://101.201.173.125:47001/api/akshare-auth?token=&version=0.2.13) 自行实现封控解除。
133
+
134
+ ## 💬 使用问题交流群
135
+
136
+ 如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
137
+
138
+ ![TVsbhbIuCF9Ga1Fwe3L2BX3s8UMauTAL.webp](https://cdn.nodeimage.com/i/TVsbhbIuCF9Ga1Fwe3L2BX3s8UMauTAL.webp)
@@ -2,9 +2,10 @@ import time
2
2
  import threading
3
3
  import requests
4
4
  from urllib.parse import urlparse
5
+ from .yfinance import install_yfinance_patch_main
5
6
 
6
- __version__ = "0.2.13"
7
- # 备份 Session 的原始 request 方法,这是所有 requests.get/post 的最终入口
7
+ __version__ = "0.3.0"
8
+ # 备份 Session 的原始 request 方法
8
9
  _original_request = requests.Session.request
9
10
  _auth_session = requests.Session()
10
11
 
@@ -57,6 +58,8 @@ default_hook_domains = [
57
58
  "emweb.securities.eastmoney.com",
58
59
  ]
59
60
 
61
+ default_yfinance_hook_domains = ["finance.yahoo.com"]
62
+
60
63
 
61
64
  def install_patch(auth_ip, auth_token="", retry=30, hook_domains=default_hook_domains):
62
65
  def patched_request(self, method, url, **kwargs):
@@ -111,13 +114,12 @@ def install_patch(auth_ip, auth_token="", retry=30, hook_domains=default_hook_do
111
114
  _cache.expire_at = 0
112
115
  time.sleep(0.05)
113
116
 
114
- # 最终尝试
115
117
  return _original_request(self, method, url, **kwargs)
116
118
 
117
- # 关键:全局替换 Session 的 request 入口
118
119
  requests.Session.request = patched_request
119
120
 
120
121
 
121
- # 使用示例
122
- # install_patch("你的IP", "你的TOKEN")
123
- # requests.get("http://fund.eastmoney.com/...")
122
+ def install_yfinance_patch(
123
+ auth_ip, auth_token="", retry=30, hook_domains=default_yfinance_hook_domains
124
+ ):
125
+ install_yfinance_patch_main(auth_ip, auth_token, retry, hook_domains)
@@ -0,0 +1,95 @@
1
+ import time
2
+ import threading
3
+ from curl_cffi import requests
4
+
5
+ __version__ = "0.3.0"
6
+ _original_request = requests.Session.request
7
+ _auth_session = requests.Session()
8
+
9
+
10
+ class AuthCache:
11
+ def __init__(self):
12
+ self.data = None
13
+ self.expire_at = 0
14
+ self.lock = threading.Lock()
15
+ self.ttl = 30
16
+
17
+
18
+ _cache = AuthCache()
19
+
20
+
21
+ def get_auth_config_with_cache(auth_url, auth_token):
22
+ now = time.time()
23
+ # 1. 检查缓存是否有效
24
+ if _cache.data and now < _cache.expire_at:
25
+ return _cache.data
26
+
27
+ # 2. 缓存失效,加锁更新
28
+ with _cache.lock:
29
+ if _cache.data and now < _cache.expire_at:
30
+ return _cache.data
31
+
32
+ try:
33
+ resp = _auth_session.get(
34
+ auth_url,
35
+ params={"token": auth_token, "version": __version__},
36
+ timeout=(1.5, 3),
37
+ )
38
+ data = resp.json()
39
+ if data.get("proxy"):
40
+ _cache.data = data
41
+ _cache.expire_at = now + _cache.ttl
42
+ return data
43
+ print(f"授权失败: {data.get('error_msg')}")
44
+ except Exception as e:
45
+ print(f"请求授权接口异常: {e}")
46
+
47
+ return _cache.data
48
+
49
+
50
+ def install_yfinance_patch_main(auth_ip, auth_token="", retry=30, hook_domains=[]):
51
+ def patched_request(self, method, url, **kwargs):
52
+ # 排除非目标域名
53
+ is_target = any(d in (url or "") for d in hook_domains)
54
+
55
+ if not is_target:
56
+ return _original_request(self, method, url, **kwargs)
57
+
58
+ auth_url = f"http://{auth_ip}:47001/api/yfinance-auth"
59
+
60
+ # 重试逻辑
61
+ for _ in range(retry):
62
+ auth_res = get_auth_config_with_cache(auth_url, auth_token)
63
+ if not auth_res:
64
+ time.sleep(0.05)
65
+ continue
66
+
67
+ kwargs["proxies"] = {
68
+ "http": auth_res["proxy"],
69
+ "https": auth_res["proxy"],
70
+ }
71
+
72
+ kwargs["timeout"] = (2.5, 5)
73
+
74
+ try:
75
+ # 调用原始 request 方法
76
+ resp = _original_request(self, method, url, **kwargs)
77
+ if resp.ok:
78
+ try:
79
+ content_type = resp.headers.get("Content-Type").lower()
80
+ if "json" not in content_type:
81
+ return resp
82
+ _ = resp.json()
83
+ return resp
84
+ except:
85
+ pass
86
+ with _cache.lock:
87
+ _cache.expire_at = 0
88
+ time.sleep(0.05)
89
+ except Exception:
90
+ with _cache.lock:
91
+ _cache.expire_at = 0
92
+ time.sleep(0.05)
93
+ return _original_request(self, method, url, **kwargs)
94
+
95
+ requests.Session.request = patched_request
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: akshare-proxy-patch
3
+ Version: 0.3.0
4
+ Summary: 针对 AkShare 和 efinance 的底层补丁,自动为东财等接口注入代理认证头,从而避免 `stock_zh_a_spot_em` 等方法报错。
5
+ Home-page: https://github.com/helloyie/akshare-proxy-patch
6
+ Author: cheapproxy.net
7
+ Author-email: cheapproxy <emezxyj1@gmail.com>
8
+ Project-URL: Homepage, https://github.com/helloyie/akshare-proxy-patch
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: requests
16
+ Requires-Dist: curl_cffi
17
+ Dynamic: author
18
+ Dynamic: home-page
19
+ Dynamic: license-file
20
+ Dynamic: requires-python
21
+
22
+ # AkShare Proxy Patch
23
+
24
+ > 针对 [AKShare](https://github.com/akfamily/akshare)、[efinance](https://github.com/Micro-sheep/efinance)、[yfinance](https://github.com/ranaroussi/yfinance) 的🐒插件补丁,自动为函数注入请求头,解决 `stock_zh_a_spot_em`、`stock_zh_a_hist`、`get_realtime_quotes` 等东财接口报错问题和 Yahoo `YFRateLimitError` 问题。
25
+
26
+ ## ✨ 特性
27
+
28
+ - `AKShare` 东财接口报错问题
29
+ - `efinance` 东财接口报错问题
30
+ - `yfinance` Yahoo接口报错问题
31
+
32
+ ## 📦 安装
33
+
34
+ 1. 安装并升级官方 [akshare](https://github.com/akfamily/akshare) 或 [efinance](https://github.com/Micro-sheep/efinance) 包
35
+
36
+ 2. 安装 `akshare-proxy-patch` 插件
37
+
38
+ ```
39
+ pip install akshare-proxy-patch==0.3.0
40
+ ```
41
+
42
+ ## 🚀 使用方法(akshare / efinance / yfinance)
43
+
44
+ 1. [点击前往插件官网](https://ak.cheapproxy.net/dashboard/akshare) 获取 `TOKEN`。
45
+
46
+ 2. `akshare` 和 `efinance` 集成:在 Python 文件顶部添加如下代码,并替换 `你的TOKEN`。
47
+
48
+ ```
49
+ # python 文件顶部添加如下代码
50
+ import akshare_proxy_patch
51
+
52
+ akshare_proxy_patch.install_patch(
53
+ "101.201.173.125",
54
+ auth_token="你的TOKEN",
55
+ retry=30,
56
+ # 封控的域名列表,可自行调整
57
+ hook_domains=[
58
+ "fund.eastmoney.com",
59
+ "push2.eastmoney.com",
60
+ "push2his.eastmoney.com",
61
+ "emweb.securities.eastmoney.com",
62
+ ],
63
+ )
64
+
65
+ # --------------------------
66
+ # 后续你的正常业务代码保持不变
67
+ # --------------------------
68
+
69
+ # 假如你使用 akshare
70
+ import akshare as ak
71
+ df = ak.stock_zh_a_spot_em()
72
+
73
+ # 假如你使用 efinance
74
+ import efinance as ef
75
+ ef.stock.get_realtime_quotes()
76
+ ```
77
+
78
+ 3. `yfinance` 集成:在 Python 文件顶部添加如下代码,并替换 `你的TOKEN`。
79
+
80
+ ```
81
+ # python 文件顶部添加如下代码
82
+ import akshare_proxy_patch
83
+
84
+ akshare_proxy_patch.install_yfinance_patch(
85
+ "101.201.173.125",
86
+ auth_token="你的TOKEN",
87
+ retry=30,
88
+ )
89
+
90
+ # --------------------------
91
+ # 后续你的正常业务代码保持不变
92
+ # --------------------------
93
+
94
+ import yfinance as yf
95
+
96
+ data = yf.download("AAPL", start="2017-01-01", end="2017-04-30")
97
+ ```
98
+
99
+ ## 📖 install_patch 参数说明
100
+
101
+ - 参数1:网关
102
+ - 默认为 `101.201.173.125` 不可修改
103
+ - 参数2:TOKEN
104
+ - 授权凭证
105
+ - 参数3:重试次数
106
+ - 默认为30,建议保持不变
107
+ - 参数4:封控的域名列表
108
+ - 接口 `URL` 包含数组中的其中一条,就会走插件。
109
+ - 可点击 `ak` 或 `ef` 函数查看接口源码对应的 `URL`,根据封控情况细化可以降低积分消耗。
110
+ - 如只封控 `stock_zh_a_spot_em` 这个接口,`hook_domains` 可设置为 `["https://82.push2.eastmoney.com/api/qt/clist/get"]`。
111
+
112
+ ## 🛠️ 如何在 aktools 内集成插件?
113
+
114
+ `aktools` 想要集成插件,需要新建一个 `akt.py` 替换官方的 `python -m aktools` 启动命令,下面是 `akt.py` 内容:
115
+
116
+ ```
117
+ # 添加插件
118
+ import akshare_proxy_patch
119
+
120
+ akshare_proxy_patch.install_patch(
121
+ "101.201.173.125",
122
+ auth_token="你的TOKEN",
123
+ retry=30,
124
+ # 封控的域名列表,可自行调整
125
+ hook_domains=[
126
+ "fund.eastmoney.com",
127
+ "push2.eastmoney.com",
128
+ "push2his.eastmoney.com",
129
+ "emweb.securities.eastmoney.com",
130
+ ],
131
+ )
132
+
133
+ # 启动 aktools
134
+ import uvicorn
135
+
136
+ if __name__ == '__main__':
137
+ uvicorn.run(
138
+ "aktools.main:app",
139
+ host="0.0.0.0",
140
+ port=8080,
141
+ reload=False,
142
+ # 根据 CPU 核心数调整,推荐 2×核心数 + 1
143
+ workers=4,
144
+ log_level="info"
145
+ )
146
+ ```
147
+
148
+ 然后执行 `python akt.py` 即可启动一个 `http://127.0.0.1:8080/` 服务。只是启动方式不同而已,使用请参考 [aktools 官方文档](https://github.com/akfamily/aktools)。
149
+
150
+ ## ❓ 我没使用 akshare 或 efinance,能集成插件吗?
151
+
152
+ - 如果使用 Python 语言的 `requests` 库请求东财接口,插件能自动 hook 住请求,正常工作。
153
+ - 如果您使用其他语言或 python 的其他库,可 [手动提取代理](http://101.201.173.125:47001/api/akshare-auth?token=&version=0.2.13) 自行实现封控解除。
154
+
155
+ ## 💬 使用问题交流群
156
+
157
+ 如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
158
+
159
+ ![TVsbhbIuCF9Ga1Fwe3L2BX3s8UMauTAL.webp](https://cdn.nodeimage.com/i/TVsbhbIuCF9Ga1Fwe3L2BX3s8UMauTAL.webp)
@@ -3,6 +3,7 @@ README.md
3
3
  pyproject.toml
4
4
  setup.py
5
5
  akshare_proxy_patch/__init__.py
6
+ akshare_proxy_patch/yfinance.py
6
7
  akshare_proxy_patch.egg-info/PKG-INFO
7
8
  akshare_proxy_patch.egg-info/SOURCES.txt
8
9
  akshare_proxy_patch.egg-info/dependency_links.txt
@@ -0,0 +1,2 @@
1
+ requests
2
+ curl_cffi
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "akshare-proxy-patch" # 包名,需在 PyPI 唯一
7
- version = "0.2.13"
7
+ version = "0.3.0"
8
8
  authors = [
9
9
  { name="cheapproxy", email="emezxyj1@gmail.com" },
10
10
  ]
@@ -13,6 +13,7 @@ readme = "README.md"
13
13
  requires-python = ">=3.7"
14
14
  dependencies = [
15
15
  "requests",
16
+ "curl_cffi",
16
17
  ]
17
18
  classifiers = [
18
19
  "Programming Language :: Python :: 3",
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="akshare-proxy-patch", # 包名,用户 pip install 时的名称
8
- version="0.2.13",
8
+ version="0.3.0",
9
9
  author="cheapproxy.net",
10
10
  author_email="emezxyj1@gmail.com",
11
11
  description="AkShare 和 efinance 报错全局Hook",
@@ -1,124 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: akshare-proxy-patch
3
- Version: 0.2.13
4
- Summary: 针对 AkShare 和 efinance 的底层补丁,自动为东财等接口注入代理认证头,从而避免 `stock_zh_a_spot_em` 等方法报错。
5
- Home-page: https://github.com/helloyie/akshare-proxy-patch
6
- Author: cheapproxy.net
7
- Author-email: cheapproxy <emezxyj1@gmail.com>
8
- Project-URL: Homepage, https://github.com/helloyie/akshare-proxy-patch
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.6
13
- Description-Content-Type: text/markdown
14
- License-File: LICENSE
15
- Requires-Dist: requests
16
- Dynamic: author
17
- Dynamic: home-page
18
- Dynamic: license-file
19
- Dynamic: requires-python
20
-
21
- # AkShare Proxy Patch
22
-
23
- 针对 `akshare` 和 `efinance` 的插件补丁,自动为接口注入请求头,解决 `stock_zh_a_spot_em`、`stock_zh_a_hist`、`get_realtime_quotes` 等东财接口报错问题。
24
-
25
- ## 安装
26
-
27
- 1. 安装好官方 [akshare](https://github.com/akfamily/akshare) 或 [efinance](https://github.com/Micro-sheep/efinance) 包
28
-
29
- 2. 安装 `akshare-proxy-patch` 插件
30
-
31
- ```
32
- pip install akshare-proxy-patch==0.2.13
33
- ```
34
-
35
- ## 使用方法
36
-
37
- `akshare` 和 `efinance` 使用方式一致,在文件顶部添加2行代码即可,无需其他额外操作。
38
-
39
- ```
40
- # python 文件顶部添加如下代码
41
- import akshare_proxy_patch
42
-
43
- akshare_proxy_patch.install_patch(
44
- "101.201.173.125",
45
- auth_token="",
46
- retry=30,
47
- hook_domains=[
48
- "fund.eastmoney.com",
49
- "push2.eastmoney.com",
50
- "push2his.eastmoney.com",
51
- "emweb.securities.eastmoney.com",
52
- ],
53
- )
54
-
55
-
56
- # 后续你的正常业务代码保持不变
57
-
58
- # 假如你使用 akshare
59
- import akshare as ak
60
- df = ak.stock_zh_a_spot_em()
61
-
62
- # 假如你使用 efinance
63
- import efinance as ef
64
- ef.stock.get_realtime_quotes()
65
- ```
66
-
67
- ## install_patch 参数说明
68
-
69
- - 参数1:网关
70
- - 默认为 `101.201.173.125` 不可修改
71
- - 参数2:TOKEN
72
- - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `TOKEN`。
73
- - 参数3:重试次数
74
- - 默认为30,建议保持不变
75
- - 参数4:需要hook的域名列表
76
- - 接口URL包含列表内任意一条域名都会走代理,可以根据封控情况调整或细化以降低积分消耗
77
- - 如只封控 `stock_zh_a_spot_em` 这个接口,hook_domains=["https://82.push2.eastmoney.com/api/qt/clist/get"] 即可(点击函数查看接口源码找到对应域名)
78
-
79
- ## 如何在 aktools 内集成插件?
80
-
81
- 需要新建一个 `akt.py` 替换官方的启动方式:
82
-
83
- ```
84
- # 添加插件
85
- import akshare_proxy_patch
86
-
87
- akshare_proxy_patch.install_patch(
88
- "101.201.173.125",
89
- auth_token="",
90
- retry=30,
91
- hook_domains=[
92
- "fund.eastmoney.com",
93
- "push2.eastmoney.com",
94
- "push2his.eastmoney.com",
95
- "emweb.securities.eastmoney.com",
96
- ],
97
- )
98
-
99
- # 启动 aktools
100
- import uvicorn
101
-
102
- if __name__ == '__main__':
103
- uvicorn.run(
104
- "aktools.main:app",
105
- host="0.0.0.0",
106
- port=8080,
107
- reload=False,
108
- # 根据 CPU 核心数调整,推荐 2×核心数 + 1
109
- workers=4,
110
- log_level="info"
111
- )
112
- ```
113
-
114
- 然后执行 `python akt.py` 即可启动并正常使用 `aktools`。
115
-
116
- ## 我是手动爬取的接口,能集成插件吗?
117
-
118
- 能。如果您没有使用 `akshare` 或 `efinance`,而是手动调用的接口,只要代码是使用的 `requests`,插件都能 hook 住请求,正常工作。
119
-
120
- ## 使用问题交流群
121
-
122
- 如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
123
-
124
- ![hx8knYwcWWnRjaPzHuWPXajFougAeGc6.webp](https://cdn.nodeimage.com/i/hx8knYwcWWnRjaPzHuWPXajFougAeGc6.webp)
@@ -1,104 +0,0 @@
1
- # AkShare Proxy Patch
2
-
3
- 针对 `akshare` 和 `efinance` 的插件补丁,自动为接口注入请求头,解决 `stock_zh_a_spot_em`、`stock_zh_a_hist`、`get_realtime_quotes` 等东财接口报错问题。
4
-
5
- ## 安装
6
-
7
- 1. 安装好官方 [akshare](https://github.com/akfamily/akshare) 或 [efinance](https://github.com/Micro-sheep/efinance) 包
8
-
9
- 2. 安装 `akshare-proxy-patch` 插件
10
-
11
- ```
12
- pip install akshare-proxy-patch==0.2.13
13
- ```
14
-
15
- ## 使用方法
16
-
17
- `akshare` 和 `efinance` 使用方式一致,在文件顶部添加2行代码即可,无需其他额外操作。
18
-
19
- ```
20
- # python 文件顶部添加如下代码
21
- import akshare_proxy_patch
22
-
23
- akshare_proxy_patch.install_patch(
24
- "101.201.173.125",
25
- auth_token="",
26
- retry=30,
27
- hook_domains=[
28
- "fund.eastmoney.com",
29
- "push2.eastmoney.com",
30
- "push2his.eastmoney.com",
31
- "emweb.securities.eastmoney.com",
32
- ],
33
- )
34
-
35
-
36
- # 后续你的正常业务代码保持不变
37
-
38
- # 假如你使用 akshare
39
- import akshare as ak
40
- df = ak.stock_zh_a_spot_em()
41
-
42
- # 假如你使用 efinance
43
- import efinance as ef
44
- ef.stock.get_realtime_quotes()
45
- ```
46
-
47
- ## install_patch 参数说明
48
-
49
- - 参数1:网关
50
- - 默认为 `101.201.173.125` 不可修改
51
- - 参数2:TOKEN
52
- - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `TOKEN`。
53
- - 参数3:重试次数
54
- - 默认为30,建议保持不变
55
- - 参数4:需要hook的域名列表
56
- - 接口URL包含列表内任意一条域名都会走代理,可以根据封控情况调整或细化以降低积分消耗
57
- - 如只封控 `stock_zh_a_spot_em` 这个接口,hook_domains=["https://82.push2.eastmoney.com/api/qt/clist/get"] 即可(点击函数查看接口源码找到对应域名)
58
-
59
- ## 如何在 aktools 内集成插件?
60
-
61
- 需要新建一个 `akt.py` 替换官方的启动方式:
62
-
63
- ```
64
- # 添加插件
65
- import akshare_proxy_patch
66
-
67
- akshare_proxy_patch.install_patch(
68
- "101.201.173.125",
69
- auth_token="",
70
- retry=30,
71
- hook_domains=[
72
- "fund.eastmoney.com",
73
- "push2.eastmoney.com",
74
- "push2his.eastmoney.com",
75
- "emweb.securities.eastmoney.com",
76
- ],
77
- )
78
-
79
- # 启动 aktools
80
- import uvicorn
81
-
82
- if __name__ == '__main__':
83
- uvicorn.run(
84
- "aktools.main:app",
85
- host="0.0.0.0",
86
- port=8080,
87
- reload=False,
88
- # 根据 CPU 核心数调整,推荐 2×核心数 + 1
89
- workers=4,
90
- log_level="info"
91
- )
92
- ```
93
-
94
- 然后执行 `python akt.py` 即可启动并正常使用 `aktools`。
95
-
96
- ## 我是手动爬取的接口,能集成插件吗?
97
-
98
- 能。如果您没有使用 `akshare` 或 `efinance`,而是手动调用的接口,只要代码是使用的 `requests`,插件都能 hook 住请求,正常工作。
99
-
100
- ## 使用问题交流群
101
-
102
- 如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
103
-
104
- ![hx8knYwcWWnRjaPzHuWPXajFougAeGc6.webp](https://cdn.nodeimage.com/i/hx8knYwcWWnRjaPzHuWPXajFougAeGc6.webp)
@@ -1,124 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: akshare-proxy-patch
3
- Version: 0.2.13
4
- Summary: 针对 AkShare 和 efinance 的底层补丁,自动为东财等接口注入代理认证头,从而避免 `stock_zh_a_spot_em` 等方法报错。
5
- Home-page: https://github.com/helloyie/akshare-proxy-patch
6
- Author: cheapproxy.net
7
- Author-email: cheapproxy <emezxyj1@gmail.com>
8
- Project-URL: Homepage, https://github.com/helloyie/akshare-proxy-patch
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.6
13
- Description-Content-Type: text/markdown
14
- License-File: LICENSE
15
- Requires-Dist: requests
16
- Dynamic: author
17
- Dynamic: home-page
18
- Dynamic: license-file
19
- Dynamic: requires-python
20
-
21
- # AkShare Proxy Patch
22
-
23
- 针对 `akshare` 和 `efinance` 的插件补丁,自动为接口注入请求头,解决 `stock_zh_a_spot_em`、`stock_zh_a_hist`、`get_realtime_quotes` 等东财接口报错问题。
24
-
25
- ## 安装
26
-
27
- 1. 安装好官方 [akshare](https://github.com/akfamily/akshare) 或 [efinance](https://github.com/Micro-sheep/efinance) 包
28
-
29
- 2. 安装 `akshare-proxy-patch` 插件
30
-
31
- ```
32
- pip install akshare-proxy-patch==0.2.13
33
- ```
34
-
35
- ## 使用方法
36
-
37
- `akshare` 和 `efinance` 使用方式一致,在文件顶部添加2行代码即可,无需其他额外操作。
38
-
39
- ```
40
- # python 文件顶部添加如下代码
41
- import akshare_proxy_patch
42
-
43
- akshare_proxy_patch.install_patch(
44
- "101.201.173.125",
45
- auth_token="",
46
- retry=30,
47
- hook_domains=[
48
- "fund.eastmoney.com",
49
- "push2.eastmoney.com",
50
- "push2his.eastmoney.com",
51
- "emweb.securities.eastmoney.com",
52
- ],
53
- )
54
-
55
-
56
- # 后续你的正常业务代码保持不变
57
-
58
- # 假如你使用 akshare
59
- import akshare as ak
60
- df = ak.stock_zh_a_spot_em()
61
-
62
- # 假如你使用 efinance
63
- import efinance as ef
64
- ef.stock.get_realtime_quotes()
65
- ```
66
-
67
- ## install_patch 参数说明
68
-
69
- - 参数1:网关
70
- - 默认为 `101.201.173.125` 不可修改
71
- - 参数2:TOKEN
72
- - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `TOKEN`。
73
- - 参数3:重试次数
74
- - 默认为30,建议保持不变
75
- - 参数4:需要hook的域名列表
76
- - 接口URL包含列表内任意一条域名都会走代理,可以根据封控情况调整或细化以降低积分消耗
77
- - 如只封控 `stock_zh_a_spot_em` 这个接口,hook_domains=["https://82.push2.eastmoney.com/api/qt/clist/get"] 即可(点击函数查看接口源码找到对应域名)
78
-
79
- ## 如何在 aktools 内集成插件?
80
-
81
- 需要新建一个 `akt.py` 替换官方的启动方式:
82
-
83
- ```
84
- # 添加插件
85
- import akshare_proxy_patch
86
-
87
- akshare_proxy_patch.install_patch(
88
- "101.201.173.125",
89
- auth_token="",
90
- retry=30,
91
- hook_domains=[
92
- "fund.eastmoney.com",
93
- "push2.eastmoney.com",
94
- "push2his.eastmoney.com",
95
- "emweb.securities.eastmoney.com",
96
- ],
97
- )
98
-
99
- # 启动 aktools
100
- import uvicorn
101
-
102
- if __name__ == '__main__':
103
- uvicorn.run(
104
- "aktools.main:app",
105
- host="0.0.0.0",
106
- port=8080,
107
- reload=False,
108
- # 根据 CPU 核心数调整,推荐 2×核心数 + 1
109
- workers=4,
110
- log_level="info"
111
- )
112
- ```
113
-
114
- 然后执行 `python akt.py` 即可启动并正常使用 `aktools`。
115
-
116
- ## 我是手动爬取的接口,能集成插件吗?
117
-
118
- 能。如果您没有使用 `akshare` 或 `efinance`,而是手动调用的接口,只要代码是使用的 `requests`,插件都能 hook 住请求,正常工作。
119
-
120
- ## 使用问题交流群
121
-
122
- 如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
123
-
124
- ![hx8knYwcWWnRjaPzHuWPXajFougAeGc6.webp](https://cdn.nodeimage.com/i/hx8knYwcWWnRjaPzHuWPXajFougAeGc6.webp)