akshare-proxy-patch 0.1.2__tar.gz → 0.1.4__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.1.2
3
+ Version: 0.1.4
4
4
  Summary: 针对 AkShare 的底层补丁,自动为东财等接口注入代理认证头,从而避免 `stock_zh_a_spot_em` 等方法报错。
5
5
  Home-page: https://github.com/helloyie/akshare-proxy-patch
6
6
  Author: cheapproxy.net
@@ -30,7 +30,7 @@ pip install --upgrade akshare-proxy-patch
30
30
 
31
31
  ## 使用
32
32
 
33
- 1. 访问 https://cheapproxy.net 联系客服,获取授权码 `AUTH_TOKEN`
33
+ 1. 访问 https://cheapproxy.net 联系客服(备注: token),获取授权码 `AUTH_IP` 和 `AUTH_TOKEN`
34
34
 
35
35
  2. 将 akshare 升级到最新
36
36
 
@@ -42,7 +42,7 @@ pip install --upgrade akshare
42
42
  ```
43
43
  import akshare_proxy_patch
44
44
 
45
- akshare_proxy_patch.install_patch("AUTH_TOKEN")
45
+ akshare_proxy_patch.install_patch("AUTH_IP", "AUTH_TOKEN")
46
46
 
47
47
 
48
48
  # import akshare as ak
@@ -9,7 +9,7 @@ pip install --upgrade akshare-proxy-patch
9
9
 
10
10
  ## 使用
11
11
 
12
- 1. 访问 https://cheapproxy.net 联系客服,获取授权码 `AUTH_TOKEN`
12
+ 1. 访问 https://cheapproxy.net 联系客服(备注: token),获取授权码 `AUTH_IP` 和 `AUTH_TOKEN`
13
13
 
14
14
  2. 将 akshare 升级到最新
15
15
 
@@ -21,7 +21,7 @@ pip install --upgrade akshare
21
21
  ```
22
22
  import akshare_proxy_patch
23
23
 
24
- akshare_proxy_patch.install_patch("AUTH_TOKEN")
24
+ akshare_proxy_patch.install_patch("AUTH_IP", "AUTH_TOKEN")
25
25
 
26
26
 
27
27
  # import akshare as ak
@@ -1,20 +1,21 @@
1
- import requests
2
1
  import time
2
+ import requests
3
3
  from requests.adapters import HTTPAdapter
4
4
 
5
5
  original_send = HTTPAdapter.send
6
6
 
7
7
 
8
- def install_patch(auth_token):
8
+ def install_patch(auth_ip, auth_token):
9
9
  def patched_send(self, request, **kwargs):
10
+ auth_url = f"http://{auth_ip}:47001/api/akshare-auth"
10
11
  url = request.url
11
- if "82.push2.eastmoney.com" not in url and "push2his.eastmoney.com" not in url:
12
- return original_send(self, request, **kwargs)
12
+ is_hook = ("push2.eastmoney.com" in url) or ("push2his.eastmoney.com" in url)
13
13
  for i in range(60):
14
14
  try:
15
+ if not is_hook:
16
+ return original_send(self, request, **kwargs)
15
17
  with requests.Session() as s:
16
18
  HTTPAdapter.send = original_send
17
- auth_url = "http://akshare.cheapproxy.net/api/akshare-auth"
18
19
  auth_res = s.get(
19
20
  auth_url, params={"token": auth_token}, timeout=5
20
21
  ).json()
@@ -28,10 +29,11 @@ def install_patch(auth_token):
28
29
  request.headers["Cookie"] = cookie_str
29
30
  proxy = auth_res["proxy"]
30
31
  kwargs["proxies"] = {"http": proxy, "https": proxy}
31
- kwargs["timeout"] = 10
32
+ kwargs["timeout"] = 8
32
33
  return original_send(self, request, **kwargs)
33
34
  except Exception as e:
34
- time.sleep(1)
35
+ if not is_hook:
36
+ time.sleep(0.5)
35
37
  HTTPAdapter.send = patched_send
36
38
 
37
39
  return original_send(self, request, **kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: akshare-proxy-patch
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: 针对 AkShare 的底层补丁,自动为东财等接口注入代理认证头,从而避免 `stock_zh_a_spot_em` 等方法报错。
5
5
  Home-page: https://github.com/helloyie/akshare-proxy-patch
6
6
  Author: cheapproxy.net
@@ -30,7 +30,7 @@ pip install --upgrade akshare-proxy-patch
30
30
 
31
31
  ## 使用
32
32
 
33
- 1. 访问 https://cheapproxy.net 联系客服,获取授权码 `AUTH_TOKEN`
33
+ 1. 访问 https://cheapproxy.net 联系客服(备注: token),获取授权码 `AUTH_IP` 和 `AUTH_TOKEN`
34
34
 
35
35
  2. 将 akshare 升级到最新
36
36
 
@@ -42,7 +42,7 @@ pip install --upgrade akshare
42
42
  ```
43
43
  import akshare_proxy_patch
44
44
 
45
- akshare_proxy_patch.install_patch("AUTH_TOKEN")
45
+ akshare_proxy_patch.install_patch("AUTH_IP", "AUTH_TOKEN")
46
46
 
47
47
 
48
48
  # import akshare as ak
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "akshare-proxy-patch" # 包名,需在 PyPI 唯一
7
- version = "0.1.2"
7
+ version = "0.1.4"
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.1.2", # 版本号
8
+ version="0.1.4", # 版本号
9
9
  author="cheapproxy.net",
10
10
  author_email="emezxyj1@gmail.com",
11
11
  description="AkShare 报错全局Hook",