🐞 fix: 紧急修复一个严重bug

This commit is contained in:
AdminWhaleFall
2022-04-27 01:36:04 +08:00
parent 65ba68b3bb
commit bd353f8d84
5 changed files with 10 additions and 7 deletions

View File

@@ -58,8 +58,12 @@ class API(BaseModel):
:param API: one API basemodel
:return: API basemodel
"""
if isinstance(self.header, str) and self.header:
if self.header == "":
self.header = {}
self.header['Referer'] = self.url # 增加 Referer
else:
self.header = self.replace_data(self.header, phone)
self.data = self.replace_data(self.data, phone)
self.url = self.replace_data(self.url, phone)
return self

View File

@@ -11,7 +11,6 @@ def test_resq(api: API, phone) -> httpx.Response:
:return: httpx 请求对象.
"""
api = api.handle_API(phone)
default_header['Referer'] = api.url
with httpx.Client(headers=default_header, timeout=8) as client:
if not isinstance(api.data, dict):
print("data")

View File

@@ -88,8 +88,6 @@ def req(api: Union[API, str], phone: tuple):
else:
phone_lst = [phone]
# 自动添加 Referer
default_header['Referer'] = api.url
with httpx.Client(headers=default_header, verify=False) as client:
for ph in phone_lst:
try:

View File

@@ -89,7 +89,6 @@ def req(api: Union[API, str], phone: tuple):
phone_lst = [_ for _ in phone]
else:
phone_lst = [phone]
default_header['Referer'] = api.url
with httpx.Client(headers=default_header, verify=False) as client:
for ph in phone_lst:
try:

View File

@@ -101,8 +101,11 @@ class API(BaseModel):
:return: API basemodel
"""
# 如果传入的 header 是字符串,就转为字典.
if (isinstance(self.header, str) and self.header):
self.header = json.loads(self.header.replace("'", '"'))
if self.header == "":
self.header = {}
self.header['Referer'] = self.url # 增加 Referer
else:
self.header = self.replace_data(self.header, phone)
self.data = self.replace_data(self.data, phone)
self.url = self.replace_data(self.url, phone)