akshare-proxy-patch 0.2.8__tar.gz → 0.2.9__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: akshare-proxy-patch
3
- Version: 0.2.8
3
+ Version: 0.2.9
4
4
  Summary: 针对 AkShare 和 efinance 的底层补丁,自动为东财等接口注入代理认证头,从而避免 `stock_zh_a_spot_em` 等方法报错。
5
5
  Home-page: https://github.com/helloyie/akshare-proxy-patch
6
6
  Author: cheapproxy.net
@@ -20,7 +20,7 @@ Dynamic: requires-python
20
20
 
21
21
  # AkShare Proxy Patch
22
22
 
23
- 针对 akshare 和 efinance 的插件补丁,自动为东财接口注入代理认证头,从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。
23
+ 针对 `akshare` 和 `efinance` 的插件补丁,自动为接口注入请求头,从而避免`stock_zh_a_spot_em`、`get_realtime_quotes` 等接口报错问题。
24
24
 
25
25
  ## 安装
26
26
 
@@ -40,7 +40,7 @@ pip install akshare-proxy-patch==0.2.8
40
40
  # python 文件顶部添加2行代码
41
41
  import akshare_proxy_patch
42
42
 
43
- akshare_proxy_patch.install_patch("101.201.173.125", "", 50)
43
+ akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
44
44
 
45
45
 
46
46
  # 后续你的正常业务代码保持不变
@@ -58,19 +58,44 @@ ef.stock.get_realtime_quotes()
58
58
 
59
59
  - 参数1:网关
60
60
  - 默认为 `101.201.173.125` 不可修改
61
- - 参数2:AUTH_TOKEN
62
- - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `AUTH_TOKEN`。
61
+ - 参数2:TOKEN
62
+ - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `TOKEN`。
63
63
  - 参数3:重试次数
64
- - 默认为50,建议保持不变
64
+ - 默认为30,建议保持不变
65
65
 
66
- ## 目前 Hook 的接口域名清单
66
+ ## 如何在 aktools 内集成插件?
67
67
 
68
- - fund.eastmoney.com
69
- - push2.eastmoney.com
70
- - push2his.eastmoney.com
68
+ 需要新建一个 `akt.py` 替换官方的启动方式:
69
+
70
+ ```
71
+ # 添加插件
72
+ import akshare_proxy_patch
73
+
74
+ akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
75
+
76
+ # 启动 aktools
77
+ import uvicorn
78
+
79
+ if __name__ == '__main__':
80
+ uvicorn.run(
81
+ "aktools.main:app",
82
+ host="0.0.0.0",
83
+ port=8080,
84
+ reload=False,
85
+ # 根据 CPU 核心数调整,推荐 2×核心数 + 1
86
+ workers=4,
87
+ log_level="info"
88
+ )
89
+ ```
90
+
91
+ 然后执行 `python akt.py` 即可启动并正常使用 `aktools`。
92
+
93
+ ## 我是手动爬取的接口,能集成插件吗?
94
+
95
+ 能。如果您没有使用 `akshare` 或 `efinance`,而是手动调用的接口,只要代码是使用的 `requests`,插件都能 hook 住请求,正常工作。
71
96
 
72
97
  ## 使用问题交流群
73
98
 
74
99
  如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
75
100
 
76
- ![cBdTtCUyUMu90DljeIpzLFD5IFqPmW9y.webp](https://cdn.nodeimage.com/i/cBdTtCUyUMu90DljeIpzLFD5IFqPmW9y.webp)
101
+ ![7sEblPiT7tEdCPrA3nEyekVYxsMZDDgy.webp](https://picui.ogmua.cn/s1/2026/03/03/69a64a45bbda0.webp)
@@ -0,0 +1,81 @@
1
+ # AkShare Proxy Patch
2
+
3
+ 针对 `akshare` 和 `efinance` 的插件补丁,自动为接口注入请求头,从而避免`stock_zh_a_spot_em`、`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.8
13
+ ```
14
+
15
+ ## 使用方法
16
+
17
+ `akshare` 和 `efinance` 使用方式一致,在文件顶部添加2行代码即可,无需其他额外操作。
18
+
19
+ ```
20
+ # python 文件顶部添加2行代码
21
+ import akshare_proxy_patch
22
+
23
+ akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
24
+
25
+
26
+ # 后续你的正常业务代码保持不变
27
+
28
+ # 假如你使用 akshare
29
+ import akshare as ak
30
+ df = ak.stock_zh_a_spot_em()
31
+
32
+ # 假如你使用 efinance
33
+ import efinance as ef
34
+ ef.stock.get_realtime_quotes()
35
+ ```
36
+
37
+ ## install_patch 参数说明
38
+
39
+ - 参数1:网关
40
+ - 默认为 `101.201.173.125` 不可修改
41
+ - 参数2:TOKEN
42
+ - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `TOKEN`。
43
+ - 参数3:重试次数
44
+ - 默认为30,建议保持不变
45
+
46
+ ## 如何在 aktools 内集成插件?
47
+
48
+ 需要新建一个 `akt.py` 替换官方的启动方式:
49
+
50
+ ```
51
+ # 添加插件
52
+ import akshare_proxy_patch
53
+
54
+ akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
55
+
56
+ # 启动 aktools
57
+ import uvicorn
58
+
59
+ if __name__ == '__main__':
60
+ uvicorn.run(
61
+ "aktools.main:app",
62
+ host="0.0.0.0",
63
+ port=8080,
64
+ reload=False,
65
+ # 根据 CPU 核心数调整,推荐 2×核心数 + 1
66
+ workers=4,
67
+ log_level="info"
68
+ )
69
+ ```
70
+
71
+ 然后执行 `python akt.py` 即可启动并正常使用 `aktools`。
72
+
73
+ ## 我是手动爬取的接口,能集成插件吗?
74
+
75
+ 能。如果您没有使用 `akshare` 或 `efinance`,而是手动调用的接口,只要代码是使用的 `requests`,插件都能 hook 住请求,正常工作。
76
+
77
+ ## 使用问题交流群
78
+
79
+ 如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
80
+
81
+ ![7sEblPiT7tEdCPrA3nEyekVYxsMZDDgy.webp](https://picui.ogmua.cn/s1/2026/03/03/69a64a45bbda0.webp)
@@ -1,9 +1,8 @@
1
1
  import time
2
2
  import threading
3
3
  import requests
4
- from requests.adapters import HTTPAdapter
5
4
 
6
- __version__ = "0.2.8"
5
+ __version__ = "0.2.9"
7
6
  # 备份 Session 的原始 request 方法,这是所有 requests.get/post 的最终入口
8
7
  _original_request = requests.Session.request
9
8
  _auth_session = requests.Session()
@@ -14,7 +13,7 @@ class AuthCache:
14
13
  self.data = None
15
14
  self.expire_at = 0
16
15
  self.lock = threading.Lock()
17
- self.ttl = 20
16
+ self.ttl = 28
18
17
 
19
18
 
20
19
  _cache = AuthCache()
@@ -35,7 +34,7 @@ def get_auth_config_with_cache(auth_url, auth_token):
35
34
  resp = _auth_session.get(
36
35
  auth_url,
37
36
  params={"token": auth_token, "version": __version__},
38
- timeout=5,
37
+ timeout=(1.5, 3),
39
38
  )
40
39
  data = resp.json()
41
40
  if data.get("ua"):
@@ -85,7 +84,7 @@ def install_patch(auth_ip, auth_token, retry=30):
85
84
  "https": auth_res["proxy"],
86
85
  }
87
86
 
88
- kwargs["timeout"] = 8
87
+ kwargs["timeout"] = (2.5, 5)
89
88
 
90
89
  try:
91
90
  # 调用原始 request 方法
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: akshare-proxy-patch
3
- Version: 0.2.8
3
+ Version: 0.2.9
4
4
  Summary: 针对 AkShare 和 efinance 的底层补丁,自动为东财等接口注入代理认证头,从而避免 `stock_zh_a_spot_em` 等方法报错。
5
5
  Home-page: https://github.com/helloyie/akshare-proxy-patch
6
6
  Author: cheapproxy.net
@@ -20,7 +20,7 @@ Dynamic: requires-python
20
20
 
21
21
  # AkShare Proxy Patch
22
22
 
23
- 针对 akshare 和 efinance 的插件补丁,自动为东财接口注入代理认证头,从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。
23
+ 针对 `akshare` 和 `efinance` 的插件补丁,自动为接口注入请求头,从而避免`stock_zh_a_spot_em`、`get_realtime_quotes` 等接口报错问题。
24
24
 
25
25
  ## 安装
26
26
 
@@ -40,7 +40,7 @@ pip install akshare-proxy-patch==0.2.8
40
40
  # python 文件顶部添加2行代码
41
41
  import akshare_proxy_patch
42
42
 
43
- akshare_proxy_patch.install_patch("101.201.173.125", "", 50)
43
+ akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
44
44
 
45
45
 
46
46
  # 后续你的正常业务代码保持不变
@@ -58,19 +58,44 @@ ef.stock.get_realtime_quotes()
58
58
 
59
59
  - 参数1:网关
60
60
  - 默认为 `101.201.173.125` 不可修改
61
- - 参数2:AUTH_TOKEN
62
- - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `AUTH_TOKEN`。
61
+ - 参数2:TOKEN
62
+ - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `TOKEN`。
63
63
  - 参数3:重试次数
64
- - 默认为50,建议保持不变
64
+ - 默认为30,建议保持不变
65
65
 
66
- ## 目前 Hook 的接口域名清单
66
+ ## 如何在 aktools 内集成插件?
67
67
 
68
- - fund.eastmoney.com
69
- - push2.eastmoney.com
70
- - push2his.eastmoney.com
68
+ 需要新建一个 `akt.py` 替换官方的启动方式:
69
+
70
+ ```
71
+ # 添加插件
72
+ import akshare_proxy_patch
73
+
74
+ akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
75
+
76
+ # 启动 aktools
77
+ import uvicorn
78
+
79
+ if __name__ == '__main__':
80
+ uvicorn.run(
81
+ "aktools.main:app",
82
+ host="0.0.0.0",
83
+ port=8080,
84
+ reload=False,
85
+ # 根据 CPU 核心数调整,推荐 2×核心数 + 1
86
+ workers=4,
87
+ log_level="info"
88
+ )
89
+ ```
90
+
91
+ 然后执行 `python akt.py` 即可启动并正常使用 `aktools`。
92
+
93
+ ## 我是手动爬取的接口,能集成插件吗?
94
+
95
+ 能。如果您没有使用 `akshare` 或 `efinance`,而是手动调用的接口,只要代码是使用的 `requests`,插件都能 hook 住请求,正常工作。
71
96
 
72
97
  ## 使用问题交流群
73
98
 
74
99
  如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
75
100
 
76
- ![cBdTtCUyUMu90DljeIpzLFD5IFqPmW9y.webp](https://cdn.nodeimage.com/i/cBdTtCUyUMu90DljeIpzLFD5IFqPmW9y.webp)
101
+ ![7sEblPiT7tEdCPrA3nEyekVYxsMZDDgy.webp](https://picui.ogmua.cn/s1/2026/03/03/69a64a45bbda0.webp)
@@ -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.8"
7
+ version = "0.2.9"
8
8
  authors = [
9
9
  { name="cheapproxy", email="emezxyj1@gmail.com" },
10
10
  ]
@@ -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.8",
8
+ version="0.2.9",
9
9
  author="cheapproxy.net",
10
10
  author_email="emezxyj1@gmail.com",
11
11
  description="AkShare 和 efinance 报错全局Hook",
@@ -1,56 +0,0 @@
1
- # AkShare Proxy Patch
2
-
3
- 针对 akshare 和 efinance 的插件补丁,自动为东财接口注入代理认证头,从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。
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.8
13
- ```
14
-
15
- ## 使用方法
16
-
17
- `akshare` 和 `efinance` 使用方式一致,在文件顶部添加2行代码即可,无需其他额外操作。
18
-
19
- ```
20
- # python 文件顶部添加2行代码
21
- import akshare_proxy_patch
22
-
23
- akshare_proxy_patch.install_patch("101.201.173.125", "", 50)
24
-
25
-
26
- # 后续你的正常业务代码保持不变
27
-
28
- # 假如你使用 akshare
29
- import akshare as ak
30
- df = ak.stock_zh_a_spot_em()
31
-
32
- # 假如你使用 efinance
33
- import efinance as ef
34
- ef.stock.get_realtime_quotes()
35
- ```
36
-
37
- ## install_patch 参数说明
38
-
39
- - 参数1:网关
40
- - 默认为 `101.201.173.125` 不可修改
41
- - 参数2:AUTH_TOKEN
42
- - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `AUTH_TOKEN`。
43
- - 参数3:重试次数
44
- - 默认为50,建议保持不变
45
-
46
- ## 目前 Hook 的接口域名清单
47
-
48
- - fund.eastmoney.com
49
- - push2.eastmoney.com
50
- - push2his.eastmoney.com
51
-
52
- ## 使用问题交流群
53
-
54
- 如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
55
-
56
- ![cBdTtCUyUMu90DljeIpzLFD5IFqPmW9y.webp](https://cdn.nodeimage.com/i/cBdTtCUyUMu90DljeIpzLFD5IFqPmW9y.webp)