Skip to content

Instantly share code, notes, and snippets.

@tritium21
Created November 16, 2017 11:00
Show Gist options
  • Select an option

  • Save tritium21/1f964078a14f7f9435234d572288a9f1 to your computer and use it in GitHub Desktop.

Select an option

Save tritium21/1f964078a14f7f9435234d572288a9f1 to your computer and use it in GitHub Desktop.
import asyncio
import aiohttp
URLS = [
"https://google.com",
"https://github.com",
"https://example.org",
]
DONE = {}
async def main():
async with aiohttp.ClientSession() as session:
for url in URLS:
async with session.get(url) as resp:
text = await resp.text()
DONE[url] = len(text)
print(DONE)
asyncio.get_event_loop().run_until_complete(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment