akshare-proxy-patch 0.2.5__tar.gz → 0.2.7__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.5
3
+ Version: 0.2.7
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
@@ -19,7 +19,7 @@ Dynamic: license-file
19
19
  Dynamic: requires-python
20
20
 
21
21
  # AkShare Proxy Patch
22
- 针对 AkShare 和 efinance 的底层补丁,自动为东财接口注入代理认证头,从而避免AKShare: `stock_zh_a_spot_em`、get_realtime_quotes: `get_realtime_quotes` 等东财 eastmoney 接口报错问题。
22
+ 针对 akshare 和 efinance 的插件补丁,自动为东财接口注入代理认证头,从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。
23
23
 
24
24
  ## 安装
25
25
 
@@ -27,20 +27,20 @@ Dynamic: requires-python
27
27
 
28
28
  ```
29
29
  # akshare 用户
30
- pip install upgrade akshare
30
+ pip install --upgrade akshare
31
31
 
32
32
  # efinance 用户
33
- pip install upgrade efinance
33
+ pip install --upgrade efinance
34
34
  ```
35
35
 
36
- 2. 安装最新版本的 `akshare-proxy-patch` 或者 ``
36
+ 2. 安装最新版本的 `akshare-proxy-patch`
37
37
  ```
38
- pip install akshare-proxy-patch==0.2.5
38
+ pip install akshare-proxy-patch==0.2.7
39
39
  ```
40
40
 
41
- 最好默认用国外源,国内源不是最新的,安装不上 0.2.5 的可以安装 0.2.4
41
+ 最好默认用国外源,国内源不是最新的,可能没更新
42
42
 
43
- ## 使用
43
+ ## 使用方法
44
44
 
45
45
  1. `akshare` 和 `efinance` 使用方式一致,在文件顶部添加如下代码
46
46
  ```
@@ -48,14 +48,15 @@ pip install akshare-proxy-patch==0.2.5
48
48
  import akshare_proxy_patch
49
49
 
50
50
  # 参数1: AUTH_IP
51
- # 参数2: AUTH_TOKEN
52
- akshare_proxy_patch.install_patch("101.201.173.125", "")
51
+ # 参数2: AUTH_TOKEN,默认为空
52
+ # 参数3: retry 重试次数,默认30
53
+ akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
53
54
 
54
- # 你的正常业务代码不变
55
+ # 你的正常业务代码保持不变
55
56
 
56
57
  # 假如使用akshare
57
- # import akshare as ak
58
- # df = ak.stock_zh_a_spot_em()
58
+ import akshare as ak
59
+ df = ak.stock_zh_a_spot_em()
59
60
 
60
61
  # 假如使用 efinance
61
62
  import efinance as ef
@@ -1,5 +1,5 @@
1
1
  # AkShare Proxy Patch
2
- 针对 AkShare 和 efinance 的底层补丁,自动为东财接口注入代理认证头,从而避免AKShare: `stock_zh_a_spot_em`、get_realtime_quotes: `get_realtime_quotes` 等东财 eastmoney 接口报错问题。
2
+ 针对 akshare 和 efinance 的插件补丁,自动为东财接口注入代理认证头,从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。
3
3
 
4
4
  ## 安装
5
5
 
@@ -7,20 +7,20 @@
7
7
 
8
8
  ```
9
9
  # akshare 用户
10
- pip install upgrade akshare
10
+ pip install --upgrade akshare
11
11
 
12
12
  # efinance 用户
13
- pip install upgrade efinance
13
+ pip install --upgrade efinance
14
14
  ```
15
15
 
16
- 2. 安装最新版本的 `akshare-proxy-patch` 或者 ``
16
+ 2. 安装最新版本的 `akshare-proxy-patch`
17
17
  ```
18
- pip install akshare-proxy-patch==0.2.5
18
+ pip install akshare-proxy-patch==0.2.7
19
19
  ```
20
20
 
21
- 最好默认用国外源,国内源不是最新的,安装不上 0.2.5 的可以安装 0.2.4
21
+ 最好默认用国外源,国内源不是最新的,可能没更新
22
22
 
23
- ## 使用
23
+ ## 使用方法
24
24
 
25
25
  1. `akshare` 和 `efinance` 使用方式一致,在文件顶部添加如下代码
26
26
  ```
@@ -28,14 +28,15 @@ pip install akshare-proxy-patch==0.2.5
28
28
  import akshare_proxy_patch
29
29
 
30
30
  # 参数1: AUTH_IP
31
- # 参数2: AUTH_TOKEN
32
- akshare_proxy_patch.install_patch("101.201.173.125", "")
31
+ # 参数2: AUTH_TOKEN,默认为空
32
+ # 参数3: retry 重试次数,默认30
33
+ akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
33
34
 
34
- # 你的正常业务代码不变
35
+ # 你的正常业务代码保持不变
35
36
 
36
37
  # 假如使用akshare
37
- # import akshare as ak
38
- # df = ak.stock_zh_a_spot_em()
38
+ import akshare as ak
39
+ df = ak.stock_zh_a_spot_em()
39
40
 
40
41
  # 假如使用 efinance
41
42
  import efinance as ef
@@ -3,7 +3,7 @@ import threading
3
3
  import requests
4
4
  from requests.adapters import HTTPAdapter
5
5
 
6
- __version__ = "0.2.5"
6
+ __version__ = "0.2.7"
7
7
  # 备份 Session 的原始 request 方法,这是所有 requests.get/post 的最终入口
8
8
  _original_request = requests.Session.request
9
9
  _auth_session = requests.Session()
@@ -49,7 +49,7 @@ 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):
52
+ def install_patch(auth_ip, auth_token, retry=30):
53
53
  def patched_request(self, method, url, **kwargs):
54
54
  # 排除非目标域名
55
55
  is_target = any(
@@ -67,7 +67,7 @@ def install_patch(auth_ip, auth_token):
67
67
  auth_url = f"http://{auth_ip}:47001/api/akshare-auth"
68
68
 
69
69
  # 重试逻辑
70
- for _ in range(10):
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
73
  time.sleep(0.5)
@@ -93,12 +93,10 @@ def install_patch(auth_ip, auth_token):
93
93
  if resp.ok:
94
94
  return resp
95
95
 
96
- # 如果遇到 403 等可能是代理失效
97
- if resp.status_code == 403:
98
- with _cache.lock:
99
- _cache.expire_at = 0
96
+ with _cache.lock:
97
+ _cache.expire_at = 0
98
+ time.sleep(0.1)
100
99
  except Exception:
101
- # 网络异常直接使缓存失效,强制下一个请求换 IP
102
100
  with _cache.lock:
103
101
  _cache.expire_at = 0
104
102
  time.sleep(0.1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: akshare-proxy-patch
3
- Version: 0.2.5
3
+ Version: 0.2.7
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
@@ -19,7 +19,7 @@ Dynamic: license-file
19
19
  Dynamic: requires-python
20
20
 
21
21
  # AkShare Proxy Patch
22
- 针对 AkShare 和 efinance 的底层补丁,自动为东财接口注入代理认证头,从而避免AKShare: `stock_zh_a_spot_em`、get_realtime_quotes: `get_realtime_quotes` 等东财 eastmoney 接口报错问题。
22
+ 针对 akshare 和 efinance 的插件补丁,自动为东财接口注入代理认证头,从而避免`akshare: stock_zh_a_spot_em`、`efinance: get_realtime_quotes` 等东财 eastmoney 接口报错问题。
23
23
 
24
24
  ## 安装
25
25
 
@@ -27,20 +27,20 @@ Dynamic: requires-python
27
27
 
28
28
  ```
29
29
  # akshare 用户
30
- pip install upgrade akshare
30
+ pip install --upgrade akshare
31
31
 
32
32
  # efinance 用户
33
- pip install upgrade efinance
33
+ pip install --upgrade efinance
34
34
  ```
35
35
 
36
- 2. 安装最新版本的 `akshare-proxy-patch` 或者 ``
36
+ 2. 安装最新版本的 `akshare-proxy-patch`
37
37
  ```
38
- pip install akshare-proxy-patch==0.2.5
38
+ pip install akshare-proxy-patch==0.2.7
39
39
  ```
40
40
 
41
- 最好默认用国外源,国内源不是最新的,安装不上 0.2.5 的可以安装 0.2.4
41
+ 最好默认用国外源,国内源不是最新的,可能没更新
42
42
 
43
- ## 使用
43
+ ## 使用方法
44
44
 
45
45
  1. `akshare` 和 `efinance` 使用方式一致,在文件顶部添加如下代码
46
46
  ```
@@ -48,14 +48,15 @@ pip install akshare-proxy-patch==0.2.5
48
48
  import akshare_proxy_patch
49
49
 
50
50
  # 参数1: AUTH_IP
51
- # 参数2: AUTH_TOKEN
52
- akshare_proxy_patch.install_patch("101.201.173.125", "")
51
+ # 参数2: AUTH_TOKEN,默认为空
52
+ # 参数3: retry 重试次数,默认30
53
+ akshare_proxy_patch.install_patch("101.201.173.125", "", 30)
53
54
 
54
- # 你的正常业务代码不变
55
+ # 你的正常业务代码保持不变
55
56
 
56
57
  # 假如使用akshare
57
- # import akshare as ak
58
- # df = ak.stock_zh_a_spot_em()
58
+ import akshare as ak
59
+ df = ak.stock_zh_a_spot_em()
59
60
 
60
61
  # 假如使用 efinance
61
62
  import efinance as ef
@@ -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.5"
7
+ version = "0.2.7"
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.5",
8
+ version="0.2.7",
9
9
  author="cheapproxy.net",
10
10
  author_email="emezxyj1@gmail.com",
11
11
  description="AkShare 和 efinance 报错全局Hook",