From 00c61d811b08f342df0864c77351e60a6a1825ad Mon Sep 17 00:00:00 2001 From: PrinceFPF Date: Fri, 29 Nov 2024 00:16:24 +0800 Subject: [PATCH] Update client.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.为Client类添加proxies参数; 2.完善了_request方法代码,使其能通过代理发送数据请求。 --- okx/client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/okx/client.py b/okx/client.py index 9c5093d..219877d 100644 --- a/okx/client.py +++ b/okx/client.py @@ -5,13 +5,14 @@ class Client(object): - def __init__(self, api_key, api_secret_key, passphrase, use_server_time=False, flag='1'): + def __init__(self, api_key, api_secret_key, passphrase, use_server_time=False, flag='1', proxies=None): self.API_KEY = api_key self.API_SECRET_KEY = api_secret_key self.PASSPHRASE = passphrase self.use_server_time = use_server_time self.flag = flag + self.proxies = proxies def _request(self, method, request_path, params): @@ -39,9 +40,9 @@ def _request(self, method, request_path, params): # print("body:", body) if method == c.GET: - response = requests.get(url, headers=header) + response = requests.get(url, headers=header, proxies=self.proxies) elif method == c.POST: - response = requests.post(url, data=body, headers=header) + response = requests.post(url, data=body, headers=header, proxies=self.proxies) # exception handle # print(response.headers)