Last active
June 30, 2022 16:05
-
-
Save hclivess/1de8d17dafddf089f5954b6b282c03e7 to your computer and use it in GitHub Desktop.
async url tester
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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