akshare-proxy-patch 0.2.12__tar.gz → 0.2.13__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.12
3
+ Version: 0.2.13
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
@@ -29,7 +29,7 @@ Dynamic: requires-python
29
29
  2. 安装 `akshare-proxy-patch` 插件
30
30
 
31
31
  ```
32
- pip install akshare-proxy-patch==0.2.11
32
+ pip install akshare-proxy-patch==0.2.13
33
33
  ```
34
34
 
35
35
  ## 使用方法
@@ -37,10 +37,20 @@ pip install akshare-proxy-patch==0.2.11
37
37
  `akshare` 和 `efinance` 使用方式一致,在文件顶部添加2行代码即可,无需其他额外操作。
38
38
 
39
39
  ```
40
- # python 文件顶部添加2行代码
40
+ # python 文件顶部添加如下代码
41
41
  import akshare_proxy_patch
42
42
 
43
- akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
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
+ )
44
54
 
45
55
 
46
56
  # 后续你的正常业务代码保持不变
@@ -62,6 +72,9 @@ ef.stock.get_realtime_quotes()
62
72
  - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `TOKEN`。
63
73
  - 参数3:重试次数
64
74
  - 默认为30,建议保持不变
75
+ - 参数4:需要hook的域名列表
76
+ - 接口URL包含列表内任意一条域名都会走代理,可以根据封控情况调整或细化以降低积分消耗
77
+ - 如只封控 `stock_zh_a_spot_em` 这个接口,hook_domains=["https://82.push2.eastmoney.com/api/qt/clist/get"] 即可(点击函数查看接口源码找到对应域名)
65
78
 
66
79
  ## 如何在 aktools 内集成插件?
67
80
 
@@ -71,7 +84,17 @@ ef.stock.get_realtime_quotes()
71
84
  # 添加插件
72
85
  import akshare_proxy_patch
73
86
 
74
- akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
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
+ )
75
98
 
76
99
  # 启动 aktools
77
100
  import uvicorn
@@ -98,4 +121,4 @@ if __name__ == '__main__':
98
121
 
99
122
  如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
100
123
 
101
- ![wPcUf9H0jIdRXSWKhk8BZ24wbDVnufQe.webp](https://cdn.nodeimage.com/i/wPcUf9H0jIdRXSWKhk8BZ24wbDVnufQe.webp)
124
+ ![hx8knYwcWWnRjaPzHuWPXajFougAeGc6.webp](https://cdn.nodeimage.com/i/hx8knYwcWWnRjaPzHuWPXajFougAeGc6.webp)
@@ -9,7 +9,7 @@
9
9
  2. 安装 `akshare-proxy-patch` 插件
10
10
 
11
11
  ```
12
- pip install akshare-proxy-patch==0.2.11
12
+ pip install akshare-proxy-patch==0.2.13
13
13
  ```
14
14
 
15
15
  ## 使用方法
@@ -17,10 +17,20 @@ pip install akshare-proxy-patch==0.2.11
17
17
  `akshare` 和 `efinance` 使用方式一致,在文件顶部添加2行代码即可,无需其他额外操作。
18
18
 
19
19
  ```
20
- # python 文件顶部添加2行代码
20
+ # python 文件顶部添加如下代码
21
21
  import akshare_proxy_patch
22
22
 
23
- akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
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
+ )
24
34
 
25
35
 
26
36
  # 后续你的正常业务代码保持不变
@@ -42,6 +52,9 @@ ef.stock.get_realtime_quotes()
42
52
  - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `TOKEN`。
43
53
  - 参数3:重试次数
44
54
  - 默认为30,建议保持不变
55
+ - 参数4:需要hook的域名列表
56
+ - 接口URL包含列表内任意一条域名都会走代理,可以根据封控情况调整或细化以降低积分消耗
57
+ - 如只封控 `stock_zh_a_spot_em` 这个接口,hook_domains=["https://82.push2.eastmoney.com/api/qt/clist/get"] 即可(点击函数查看接口源码找到对应域名)
45
58
 
46
59
  ## 如何在 aktools 内集成插件?
47
60
 
@@ -51,7 +64,17 @@ ef.stock.get_realtime_quotes()
51
64
  # 添加插件
52
65
  import akshare_proxy_patch
53
66
 
54
- akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
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
+ )
55
78
 
56
79
  # 启动 aktools
57
80
  import uvicorn
@@ -78,4 +101,4 @@ if __name__ == '__main__':
78
101
 
79
102
  如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
80
103
 
81
- ![wPcUf9H0jIdRXSWKhk8BZ24wbDVnufQe.webp](https://cdn.nodeimage.com/i/wPcUf9H0jIdRXSWKhk8BZ24wbDVnufQe.webp)
104
+ ![hx8knYwcWWnRjaPzHuWPXajFougAeGc6.webp](https://cdn.nodeimage.com/i/hx8knYwcWWnRjaPzHuWPXajFougAeGc6.webp)
@@ -3,7 +3,7 @@ import threading
3
3
  import requests
4
4
  from urllib.parse import urlparse
5
5
 
6
- __version__ = "0.2.12"
6
+ __version__ = "0.2.13"
7
7
  # 备份 Session 的原始 request 方法,这是所有 requests.get/post 的最终入口
8
8
  _original_request = requests.Session.request
9
9
  _auth_session = requests.Session()
@@ -49,18 +49,19 @@ def get_auth_config_with_cache(auth_url, auth_token):
49
49
  return _cache.data
50
50
 
51
51
 
52
- def install_patch(auth_ip, auth_token, retry=30):
52
+ # 如果访问的 URL 包含以下域名,走代理
53
+ default_hook_domains = [
54
+ "fund.eastmoney.com",
55
+ "push2.eastmoney.com",
56
+ "push2his.eastmoney.com",
57
+ "emweb.securities.eastmoney.com",
58
+ ]
59
+
60
+
61
+ def install_patch(auth_ip, auth_token="", retry=30, hook_domains=default_hook_domains):
53
62
  def patched_request(self, method, url, **kwargs):
54
63
  # 排除非目标域名
55
- is_target = any(
56
- d in (url or "")
57
- for d in [
58
- "fund.eastmoney.com",
59
- "push2.eastmoney.com",
60
- "push2his.eastmoney.com",
61
- "emweb.securities.eastmoney.com",
62
- ]
63
- )
64
+ is_target = any(d in (url or "") for d in hook_domains)
64
65
  is_js = urlparse(url or "").path.lower().endswith(".js")
65
66
  is_html = urlparse(url or "").path.lower().endswith(".html")
66
67
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: akshare-proxy-patch
3
- Version: 0.2.12
3
+ Version: 0.2.13
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
@@ -29,7 +29,7 @@ Dynamic: requires-python
29
29
  2. 安装 `akshare-proxy-patch` 插件
30
30
 
31
31
  ```
32
- pip install akshare-proxy-patch==0.2.11
32
+ pip install akshare-proxy-patch==0.2.13
33
33
  ```
34
34
 
35
35
  ## 使用方法
@@ -37,10 +37,20 @@ pip install akshare-proxy-patch==0.2.11
37
37
  `akshare` 和 `efinance` 使用方式一致,在文件顶部添加2行代码即可,无需其他额外操作。
38
38
 
39
39
  ```
40
- # python 文件顶部添加2行代码
40
+ # python 文件顶部添加如下代码
41
41
  import akshare_proxy_patch
42
42
 
43
- akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
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
+ )
44
54
 
45
55
 
46
56
  # 后续你的正常业务代码保持不变
@@ -62,6 +72,9 @@ ef.stock.get_realtime_quotes()
62
72
  - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `TOKEN`。
63
73
  - 参数3:重试次数
64
74
  - 默认为30,建议保持不变
75
+ - 参数4:需要hook的域名列表
76
+ - 接口URL包含列表内任意一条域名都会走代理,可以根据封控情况调整或细化以降低积分消耗
77
+ - 如只封控 `stock_zh_a_spot_em` 这个接口,hook_domains=["https://82.push2.eastmoney.com/api/qt/clist/get"] 即可(点击函数查看接口源码找到对应域名)
65
78
 
66
79
  ## 如何在 aktools 内集成插件?
67
80
 
@@ -71,7 +84,17 @@ ef.stock.get_realtime_quotes()
71
84
  # 添加插件
72
85
  import akshare_proxy_patch
73
86
 
74
- akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
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
+ )
75
98
 
76
99
  # 启动 aktools
77
100
  import uvicorn
@@ -98,4 +121,4 @@ if __name__ == '__main__':
98
121
 
99
122
  如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
100
123
 
101
- ![wPcUf9H0jIdRXSWKhk8BZ24wbDVnufQe.webp](https://cdn.nodeimage.com/i/wPcUf9H0jIdRXSWKhk8BZ24wbDVnufQe.webp)
124
+ ![hx8knYwcWWnRjaPzHuWPXajFougAeGc6.webp](https://cdn.nodeimage.com/i/hx8knYwcWWnRjaPzHuWPXajFougAeGc6.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.12"
7
+ version = "0.2.13"
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.12",
8
+ version="0.2.13",
9
9
  author="cheapproxy.net",
10
10
  author_email="emezxyj1@gmail.com",
11
11
  description="AkShare 和 efinance 报错全局Hook",