2021-06-13 02:33:38 +00:00
|
|
|
|
try:
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 优先使用httpx,在httpx无法使用的环境下使用requests
|
2021-06-13 02:33:38 +00:00
|
|
|
|
import httpx
|
2021-10-25 14:53:34 +00:00
|
|
|
|
|
2022-07-06 01:58:11 +00:00
|
|
|
|
http = httpx.Client(timeout=20, transport=httpx.HTTPTransport(retries=10))
|
2021-10-25 14:53:34 +00:00
|
|
|
|
# 当openssl版本小于1.0.2的时候直接进行一个空请求让httpx报错
|
2021-06-14 00:05:37 +00:00
|
|
|
|
import tools
|
2022-04-24 05:06:26 +00:00
|
|
|
|
|
2022-01-06 05:49:25 +00:00
|
|
|
|
if tools.get_openssl_version() <= 102:
|
2021-06-14 00:05:37 +00:00
|
|
|
|
httpx.get()
|
2022-04-24 05:06:26 +00:00
|
|
|
|
except (TypeError, ModuleNotFoundError):
|
2021-06-13 02:33:38 +00:00
|
|
|
|
import requests
|
2021-12-02 02:54:24 +00:00
|
|
|
|
from requests.adapters import HTTPAdapter
|
2022-04-24 05:06:26 +00:00
|
|
|
|
|
2021-12-02 02:54:24 +00:00
|
|
|
|
http = requests.Session()
|
2022-07-06 01:58:11 +00:00
|
|
|
|
http.mount('http://', HTTPAdapter(max_retries=10))
|
|
|
|
|
http.mount('https://', HTTPAdapter(max_retries=10))
|