From 6702945ed8347e3261c4cd74edae63b1eb5cd09c Mon Sep 17 00:00:00 2001 From: Womsxd <45663319+Womsxd@users.noreply.github.com> Date: Thu, 2 Dec 2021 10:54:24 +0800 Subject: [PATCH] =?UTF-8?q?http=E8=B6=85=E6=97=B6=E9=87=8D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- request.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/request.py b/request.py index 88ca8f3..9226df7 100644 --- a/request.py +++ b/request.py @@ -2,16 +2,17 @@ try: # 优先使用httpx,在httpx无法使用的环境下使用requests import httpx - http = httpx + http = httpx.Client(timeout=10, transport=httpx.HTTPTransport(retries=5)) # 当openssl版本小于1.0.2的时候直接进行一个空请求让httpx报错 import tools - if tools.Get_openssl_Version() <= 102: httpx.get() except: import requests - - http = requests + from requests.adapters import HTTPAdapter + http = requests.Session() + http.mount('http://', HTTPAdapter(max_retries=5)) + http.mount('https://', HTTPAdapter(max_retries=5)) # 这里实际上应该加个"-> dict"但是考虑到请求可能失败的关系,所以直接不声明返回变量