From 9b226ebfbb5e9deeed40b913a6a1747dedc8a683 Mon Sep 17 00:00:00 2001 From: AdminWhaleFall Date: Tue, 26 Apr 2022 21:53:55 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E7=BB=99=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B7=BB=E5=8A=A0=20Referer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flask_app/utils.py | 1 + smsboom.py | 3 ++- smsboom_pyinstall.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/flask_app/utils.py b/flask_app/utils.py index ffe3691..d70936e 100644 --- a/flask_app/utils.py +++ b/flask_app/utils.py @@ -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") diff --git a/smsboom.py b/smsboom.py index c0a5486..63c57a2 100644 --- a/smsboom.py +++ b/smsboom.py @@ -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: diff --git a/smsboom_pyinstall.py b/smsboom_pyinstall.py index b2ba648..93a8d4a 100644 --- a/smsboom_pyinstall.py +++ b/smsboom_pyinstall.py @@ -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: