From 3b12170d003ba2ea5003340cef7304206469356c Mon Sep 17 00:00:00 2001 From: Womsxd <45663319+Womsxd@users.noreply.github.com> Date: Mon, 14 Jun 2021 08:05:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=E5=88=A4=E6=96=ADopenssl?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=9D=A5=E9=98=B2=E6=AD=A2=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- request.py | 6 +++++- tools.py | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/request.py b/request.py index e61d705..00df014 100644 --- a/request.py +++ b/request.py @@ -2,7 +2,11 @@ try: #优先使用httpx,在httpx无法使用的环境下使用requests import httpx http = httpx -except ImportError: + #当openssl版本小于1.0.2的时候直接进行一个空请求让httpx报错 + import tools + if tools.Get_openssl_Version() < 102: + httpx.get() +except: import requests http = requests diff --git a/tools.py b/tools.py index 87270bc..f761e77 100644 --- a/tools.py +++ b/tools.py @@ -1,4 +1,5 @@ import os +import ssl import uuid import time import config @@ -62,4 +63,9 @@ def Get_item(raw_data:dict) ->str: def Nextday() -> int: now_time = int(time.time()) nextday_time = now_time - now_time % 86400 + time.timezone + 86400 - return nextday_time \ No newline at end of file + return nextday_time + +#获取Openssl版本 +def Get_openssl_Version() ->int: + temp_List = ssl.OPENSSL_VERSION_INFO + return int(f"{str(temp_List[0])}{str(temp_List[1])}{str(temp_List[2])}") \ No newline at end of file