feat: 给请求自动添加 Referer

This commit is contained in:
AdminWhaleFall
2022-04-26 21:53:55 +08:00
parent 9b08847697
commit 9b226ebfbb
3 changed files with 4 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ 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

@@ -70,7 +70,6 @@ def load_getapi() -> list:
# return None
raise ValueError
def reqAPI(api: API, client: httpx.Client) -> httpx.Response:
if isinstance(api.data, dict):
resp = client.request(method=api.method, json=api.data,
@@ -89,6 +88,8 @@ 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,7 @@ 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: