用户:LAG的1048576一枚查看:11 回复:9 评论:11 创建时间:2020-05-08T15:12:53
F12,走起!
import aiohttp,asyncio
from threading import Thread
times=1
headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; ) AppleWebKit/537.36 (KH喵L, like Gecko) Chrome/81.0.4044.92 Safari/537.36"}
async def visit(pid):
global times
for x in range(3):
async with aiohttp.ClientSession() as session:
async with session.get("https://api.cod喵/web/forums/posts/"+pid+"/details") as resp:
print(times,":visit ",pid,"\tstatus ",resp.status,sep="")
times+=1
def start(pid):
new_loop = asyncio.new_event_loop()
asyncio.set_event_loop(new_loop)
loop=asyncio.get_event_loop()
loop.run_until_complete(asyncio.gather(*[visit(pid) for i in range(100)]))
def _main_(pid):
for x in range(5):
threads=[Thread(target=start,args=(pid,)) for x in range(6)]
for t in threads:
t.setDaemon(True)
t.start()
for t in threads:
t.join()
def _mmain_(pid):
for x in range(5):
threads=[Thread(target=_main_,args=(pid,)) for x in range(6)]
for t in threads:
t.setDaemon(True)
t.start()
for t in threads:
t.join()
_mmain_("291833")点赞0
评论