diff --git a/celery_server/utils.py b/celery_server/utils.py index 946f51c1..d2a8c5b8 100644 --- a/celery_server/utils.py +++ b/celery_server/utils.py @@ -3,7 +3,7 @@ from smsboom import load_getapi, load_json from utils.log import logger from utils.models import API -from utils import default_header +from utils import default_header_user_agent import httpx from httpx import Limits from typing import Union, List @@ -37,7 +37,7 @@ async def asyncReqs(src: Union[API, str], phone: Union[tuple, str], semaphore): async with httpx.AsyncClient( limits=Limits(max_connections=1000, max_keepalive_connections=2000), - headers=default_header, + headers=default_header_user_agent(), verify=False, timeout=99999 ) as c: diff --git a/flask_app/utils.py b/flask_app/utils.py index 8d85dea6..d3c290c4 100755 --- a/flask_app/utils.py +++ b/flask_app/utils.py @@ -1,6 +1,6 @@ # encoding=utf8 import httpx -from .model import API, default_header +from .model import API, default_header_user_agent def test_resq(api: API, phone) -> httpx.Response: @@ -10,7 +10,7 @@ def test_resq(api: API, phone) -> httpx.Response: :return: httpx 请求对象. """ api = api.handle_API(phone) - with httpx.Client(headers=default_header, timeout=8) as client: + with httpx.Client(headers=default_header_user_agent(), timeout=8) as client: # 这个判断没意义.....但是我不知道怎么优化... # https://stackoverflow.com/questions/26685248/difference-between-data-and-json-parameters-in-python-requests-package # Todo: json 和 data 表单发送的问题,有些服务器不能解释 json,只能接受表单 diff --git a/handle_api.py b/handle_api.py index c0272829..1e266831 100644 --- a/handle_api.py +++ b/handle_api.py @@ -10,7 +10,7 @@ import asyncio from utils.sql import Sql -from utils.req import reqFunc, default_header +from utils.req import reqFunc, default_header_user_agent from utils.log import logger path = Path(__file__).parent.absolute().joinpath("debug", "api.db") @@ -51,7 +51,7 @@ async def test2(): while not q.empty(): i = q.get() _i = i.replace("[phone]", "19820294267") - async with httpx.AsyncClient(headers=default_header, timeout=100, limits=Limits(max_connections=1000, max_keepalive_connections=20), verify=False) as client: + async with httpx.AsyncClient(headers=default_header_user_agent(), timeout=100, limits=Limits(max_connections=1000, max_keepalive_connections=20), verify=False) as client: try: await client.get(_i) # if r.status_code == 200: diff --git a/smsboom_pyinstall.py b/smsboom_pyinstall.py index d1dbcb13..0fa375ee 100755 --- a/smsboom_pyinstall.py +++ b/smsboom_pyinstall.py @@ -11,7 +11,7 @@ import time import sys import os -from utils import API, default_header +from utils import API, default_header_user_agent # logger config logger.remove() @@ -89,7 +89,7 @@ def req(api: Union[API, str], phone: tuple): phone_lst = [_ for _ in phone] else: phone_lst = [phone] - with httpx.Client(headers=default_header, verify=False) as client: + with httpx.Client(headers=default_header_user_agent(), verify=False) as client: for ph in phone_lst: try: if isinstance(api, API): @@ -98,7 +98,7 @@ def req(api: Union[API, str], phone: tuple): logger.info(f"{api.desc}-{resp.text[:30]}") else: api = api.replace("[phone]", ph) - resp = client.get(url=api, headers=default_header) + resp = client.get(url=api, headers=default_header_user_agent()) logger.info(f"GETAPI接口-{resp.text[:30]}") except httpx.HTTPError as why: logger.error(f"{why.request.url}请求失败{why}") @@ -149,8 +149,8 @@ def update(proxy: str): try: with httpx.Client(verify=False, timeout=10) as client: # print(API_json_url) - GETAPI_json = client.get(GETAPI_json_url, headers=default_header).content.decode(encoding="utf8") - api_json = client.get(API_json_url, headers=default_header).content.decode(encoding="utf8") + GETAPI_json = client.get(GETAPI_json_url, headers=default_header_user_agent()).content.decode(encoding="utf8") + api_json = client.get(API_json_url, headers=default_header_user_agent()).content.decode(encoding="utf8") except Exception as why: logger.error(f"拉取更新失败:{why}请多尝试几次!") diff --git a/socks4_proxy.txt b/socks4_proxy.txt index 1e15b4a9..e69de29b 100644 --- a/socks4_proxy.txt +++ b/socks4_proxy.txt @@ -1 +0,0 @@ -127.0.0.1:7890 \ No newline at end of file diff --git a/utils/req.py b/utils/req.py index 9b27cea4..f9107dcf 100644 --- a/utils/req.py +++ b/utils/req.py @@ -89,7 +89,7 @@ async def asyncReqs(src: Union[API, str], phone: Union[tuple, str], semaphore): async with httpx.AsyncClient( limits=Limits(max_connections=1000, max_keepalive_connections=2000), - headers=default_header, + headers=default_header_user_agent(), verify=False, timeout=99999 ) as c: