| 12345678910111213141516171819202122232425262728 |
- import aiohttp
- import asyncio
- # 您提供的代理信息
- proxy = 'http://s8P7v8:mmVgdf@45.158.197.113:8000'
- async def fetch(session, url):
- # 使用代理
- async with session.get(url, proxy=proxy) as response:
- return await response.text()
- async def main():
- urls = [
- "https://api.ip.cc",
- "https://icanhazip.com"
- ]
- async with aiohttp.ClientSession() as session:
- tasks = [fetch(session, url) for url in urls]
- results = await asyncio.gather(*tasks)
- for result in results:
- print(result)
- print()
- # 运行异步主函数
- asyncio.run(main())
|