akshare-proxy-patch 0.2.6__tar.gz → 0.2.8__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,76 @@
1
+ Metadata-Version: 2.4
2
+ Name: akshare-proxy-patch
3
+ Version: 0.2.8
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/cheapproxy/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 的插件补丁,自动为东财接口注入代理认证头,从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。
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.8
33
+ ```
34
+
35
+ ## 使用方法
36
+
37
+ `akshare` 和 `efinance` 使用方式一致,在文件顶部添加2行代码即可,无需其他额外操作。
38
+
39
+ ```
40
+ # python 文件顶部添加2行代码
41
+ import akshare_proxy_patch
42
+
43
+ akshare_proxy_patch.install_patch("101.201.173.125", "", 50)
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
+ ## install_patch 参数说明
58
+
59
+ - 参数1:网关
60
+ - 默认为 `101.201.173.125` 不可修改
61
+ - 参数2:AUTH_TOKEN
62
+ - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `AUTH_TOKEN`。
63
+ - 参数3:重试次数
64
+ - 默认为50,建议保持不变
65
+
66
+ ## 目前 Hook 的接口域名清单
67
+
68
+ - fund.eastmoney.com
69
+ - push2.eastmoney.com
70
+ - push2his.eastmoney.com
71
+
72
+ ## 使用问题交流群
73
+
74
+ 如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
75
+
76
+ ![cBdTtCUyUMu90DljeIpzLFD5IFqPmW9y.webp](https://cdn.nodeimage.com/i/cBdTtCUyUMu90DljeIpzLFD5IFqPmW9y.webp)
@@ -0,0 +1,56 @@
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)
@@ -3,7 +3,7 @@ import threading
3
3
  import requests
4
4
  from requests.adapters import HTTPAdapter
5
5
 
6
- __version__ = "0.2.6"
6
+ __version__ = "0.2.8"
7
7
  # 备份 Session 的原始 request 方法,这是所有 requests.get/post 的最终入口
8
8
  _original_request = requests.Session.request
9
9
  _auth_session = requests.Session()
@@ -70,7 +70,7 @@ def install_patch(auth_ip, auth_token, retry=30):
70
70
  for _ in range(retry):
71
71
  auth_res = get_auth_config_with_cache(auth_url, auth_token)
72
72
  if not auth_res:
73
- time.sleep(0.5)
73
+ time.sleep(0.05)
74
74
  continue
75
75
 
76
76
  # 处理 Headers:确保不破坏业务代码传入的 headers
@@ -91,17 +91,18 @@ def install_patch(auth_ip, auth_token, retry=30):
91
91
  # 调用原始 request 方法
92
92
  resp = _original_request(self, method, url, **kwargs)
93
93
  if resp.ok:
94
- return resp
95
-
96
- # 如果遇到 403 等可能是代理失效
97
- if resp.status_code == 403:
98
- with _cache.lock:
99
- _cache.expire_at = 0
94
+ try:
95
+ _ = resp.json()
96
+ return resp
97
+ except:
98
+ pass
99
+ with _cache.lock:
100
+ _cache.expire_at = 0
101
+ time.sleep(0.05)
100
102
  except Exception:
101
- # 网络异常直接使缓存失效,强制下一个请求换 IP
102
103
  with _cache.lock:
103
104
  _cache.expire_at = 0
104
- time.sleep(0.1)
105
+ time.sleep(0.05)
105
106
 
106
107
  # 最终尝试
107
108
  return _original_request(self, method, url, **kwargs)
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.4
2
+ Name: akshare-proxy-patch
3
+ Version: 0.2.8
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/cheapproxy/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 的插件补丁,自动为东财接口注入代理认证头,从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。
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.8
33
+ ```
34
+
35
+ ## 使用方法
36
+
37
+ `akshare` 和 `efinance` 使用方式一致,在文件顶部添加2行代码即可,无需其他额外操作。
38
+
39
+ ```
40
+ # python 文件顶部添加2行代码
41
+ import akshare_proxy_patch
42
+
43
+ akshare_proxy_patch.install_patch("101.201.173.125", "", 50)
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
+ ## install_patch 参数说明
58
+
59
+ - 参数1:网关
60
+ - 默认为 `101.201.173.125` 不可修改
61
+ - 参数2:AUTH_TOKEN
62
+ - 默认为空,每天可免费使用一定次数。如有更多需求,可[点击此处注册](https://ak.cheapproxy.net/dashboard/akshare)申请正式的 `AUTH_TOKEN`。
63
+ - 参数3:重试次数
64
+ - 默认为50,建议保持不变
65
+
66
+ ## 目前 Hook 的接口域名清单
67
+
68
+ - fund.eastmoney.com
69
+ - push2.eastmoney.com
70
+ - push2his.eastmoney.com
71
+
72
+ ## 使用问题交流群
73
+
74
+ 如使用时遇到问题,或对插件有什么意见或建议,可进群交流:
75
+
76
+ ![cBdTtCUyUMu90DljeIpzLFD5IFqPmW9y.webp](https://cdn.nodeimage.com/i/cBdTtCUyUMu90DljeIpzLFD5IFqPmW9y.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.6"
7
+ version = "0.2.8"
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.6",
8
+ version="0.2.8",
9
9
  author="cheapproxy.net",
10
10
  author_email="emezxyj1@gmail.com",
11
11
  description="AkShare 和 efinance 报错全局Hook",
@@ -1,75 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: akshare-proxy-patch
3
- Version: 0.2.6
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/cheapproxy/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
- 针对 AkShare 和 efinance 的底层补丁,自动为东财接口注入代理认证头,从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。
23
-
24
- ## 安装
25
-
26
- 1. 将官方 [akshare](https://github.com/akfamily/akshare) 或 [efinance](https://github.com/Micro-sheep/efinance) 升级到最新
27
-
28
- ```
29
- # akshare 用户
30
- pip install upgrade akshare
31
-
32
- # efinance 用户
33
- pip install upgrade efinance
34
- ```
35
-
36
- 2. 安装最新版本的 `akshare-proxy-patch`
37
- ```
38
- pip install akshare-proxy-patch==0.2.6
39
- ```
40
-
41
- 最好默认用国外源,国内源不是最新的,版本必须 >=0.2.4
42
-
43
- ## 使用方法
44
-
45
- 1. `akshare` 和 `efinance` 使用方式一致,在文件顶部添加如下代码
46
- ```
47
- # 文件顶部添加
48
- import akshare_proxy_patch
49
-
50
- # 参数1: AUTH_IP
51
- # 参数2: AUTH_TOKEN,默认为空
52
- # 参数3: retry 重试次数,默认30
53
- akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
54
-
55
- # 你的正常业务代码不变
56
-
57
- # 假如使用akshare
58
- # import akshare as ak
59
- # df = ak.stock_zh_a_spot_em()
60
-
61
- # 假如使用 efinance
62
- import efinance as ef
63
- ef.stock.get_realtime_quotes()
64
- ```
65
-
66
- ## 目前Hook的接口域名清单
67
- - fund.eastmoney.com
68
- - push2.eastmoney.com
69
- - push2his.eastmoney.com
70
-
71
- ## 使用问题交流群
72
-
73
- 如遇到部分接口报错,可进群交流:
74
-
75
- ![8jmzvNOjKWFzwNUDW0Xiytcpfr50uMr5.webp](https://cdn.nodeimage.com/i/8jmzvNOjKWFzwNUDW0Xiytcpfr50uMr5.webp)
@@ -1,55 +0,0 @@
1
- # AkShare Proxy Patch
2
- 针对 AkShare 和 efinance 的底层补丁,自动为东财接口注入代理认证头,从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。
3
-
4
- ## 安装
5
-
6
- 1. 将官方 [akshare](https://github.com/akfamily/akshare) 或 [efinance](https://github.com/Micro-sheep/efinance) 升级到最新
7
-
8
- ```
9
- # akshare 用户
10
- pip install upgrade akshare
11
-
12
- # efinance 用户
13
- pip install upgrade efinance
14
- ```
15
-
16
- 2. 安装最新版本的 `akshare-proxy-patch`
17
- ```
18
- pip install akshare-proxy-patch==0.2.6
19
- ```
20
-
21
- 最好默认用国外源,国内源不是最新的,版本必须 >=0.2.4
22
-
23
- ## 使用方法
24
-
25
- 1. `akshare` 和 `efinance` 使用方式一致,在文件顶部添加如下代码
26
- ```
27
- # 文件顶部添加
28
- import akshare_proxy_patch
29
-
30
- # 参数1: AUTH_IP
31
- # 参数2: AUTH_TOKEN,默认为空
32
- # 参数3: retry 重试次数,默认30
33
- akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
34
-
35
- # 你的正常业务代码不变
36
-
37
- # 假如使用akshare
38
- # import akshare as ak
39
- # df = ak.stock_zh_a_spot_em()
40
-
41
- # 假如使用 efinance
42
- import efinance as ef
43
- ef.stock.get_realtime_quotes()
44
- ```
45
-
46
- ## 目前Hook的接口域名清单
47
- - fund.eastmoney.com
48
- - push2.eastmoney.com
49
- - push2his.eastmoney.com
50
-
51
- ## 使用问题交流群
52
-
53
- 如遇到部分接口报错,可进群交流:
54
-
55
- ![8jmzvNOjKWFzwNUDW0Xiytcpfr50uMr5.webp](https://cdn.nodeimage.com/i/8jmzvNOjKWFzwNUDW0Xiytcpfr50uMr5.webp)
@@ -1,75 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: akshare-proxy-patch
3
- Version: 0.2.6
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/cheapproxy/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
- 针对 AkShare 和 efinance 的底层补丁,自动为东财接口注入代理认证头,从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。
23
-
24
- ## 安装
25
-
26
- 1. 将官方 [akshare](https://github.com/akfamily/akshare) 或 [efinance](https://github.com/Micro-sheep/efinance) 升级到最新
27
-
28
- ```
29
- # akshare 用户
30
- pip install upgrade akshare
31
-
32
- # efinance 用户
33
- pip install upgrade efinance
34
- ```
35
-
36
- 2. 安装最新版本的 `akshare-proxy-patch`
37
- ```
38
- pip install akshare-proxy-patch==0.2.6
39
- ```
40
-
41
- 最好默认用国外源,国内源不是最新的,版本必须 >=0.2.4
42
-
43
- ## 使用方法
44
-
45
- 1. `akshare` 和 `efinance` 使用方式一致,在文件顶部添加如下代码
46
- ```
47
- # 文件顶部添加
48
- import akshare_proxy_patch
49
-
50
- # 参数1: AUTH_IP
51
- # 参数2: AUTH_TOKEN,默认为空
52
- # 参数3: retry 重试次数,默认30
53
- akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
54
-
55
- # 你的正常业务代码不变
56
-
57
- # 假如使用akshare
58
- # import akshare as ak
59
- # df = ak.stock_zh_a_spot_em()
60
-
61
- # 假如使用 efinance
62
- import efinance as ef
63
- ef.stock.get_realtime_quotes()
64
- ```
65
-
66
- ## 目前Hook的接口域名清单
67
- - fund.eastmoney.com
68
- - push2.eastmoney.com
69
- - push2his.eastmoney.com
70
-
71
- ## 使用问题交流群
72
-
73
- 如遇到部分接口报错,可进群交流:
74
-
75
- ![8jmzvNOjKWFzwNUDW0Xiytcpfr50uMr5.webp](https://cdn.nodeimage.com/i/8jmzvNOjKWFzwNUDW0Xiytcpfr50uMr5.webp)