import asyncio
import time
import cloudbypass
import aiohttp
proxy = cloudbypass.Proxy("去面板提取").set_region("US")
proxy = proxy.format("http://{username}:{password}@{gateway}")
async def task(t1, num):
async with aiohttp.ClientSession() as sess:
async with sess.get("https://ipinfo.io/ip", proxy=proxy) as resp:
t2 = time.time()
print(f'[{num}]', resp.status, await resp.text(), t2 - t1)
async def main():
t1 = time.time()
tasks = [
task(t1, _) for _ in range(10)
]
await asyncio.gather(*tasks)
if __name__ == '__main__':
asyncio.run(main())注意:穿云代理IP仅提供海外动态代理IP,在中国大陆IP环境下直连时可能会出现不稳定的情况,但您可以通过以下两种方式解决:一是将其部署在香港等境外服务器上使用;二是在本地电脑端开启TUN模式的全局代理进行中转。