Skip to content

Instantly share code, notes, and snippets.

@hclivess
Last active June 30, 2022 16:05
Show Gist options
  • Select an option

  • Save hclivess/1de8d17dafddf089f5954b6b282c03e7 to your computer and use it in GitHub Desktop.

Select an option

Save hclivess/1de8d17dafddf089f5954b6b282c03e7 to your computer and use it in GitHub Desktop.
async url tester
import aiohttp
import asyncio
async def test(ip):
async with aiohttp.ClientSession() as session:
async with session.get(ip) as response:
print(f"Running test for: {ip}")
html = await response.text()
print(f"Body: {html[:15]}...")
async def compound(ips):
result = list(filter(None, await asyncio.gather(*[test(ip) for ip in ips])))
return result
ips = ["http://127.0.0.1:9173", "http://8.8.8.8:1111", "http://127.0.0.1:9173", "http://8.8.8.8:1111", "http://127.0.0.1:9173"]
asyncio.run(compound(ips))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment