Skip to content

Instantly share code, notes, and snippets.

@0xsha
Created November 4, 2019 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xsha/9bb8e69b513027119e66ce520782eb2c to your computer and use it in GitHub Desktop.
Save 0xsha/9bb8e69b513027119e66ce520782eb2c to your computer and use it in GitHub Desktop.
# 0xsha.io
# 11/2019
import aiohttp
import asyncio
import time
urls = ["https://0xsha.io","https://twitter.com", "https://google.com", "https://yahoo.com", "https://facebook.com", "https://msn.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com",
"https://bing.com", "https://golang.org", "https://twitter.com", "https://netflix.com"
]
async def fetch(session, url):
async with session.get(url) as response:
return await response.text()
async def main():
async with aiohttp.ClientSession() as session:
start = time.time()
print(f"started at {time.strftime('%X')}")
for url in urls:
await fetch(session, url)
end = time.time()
print(f"started at {time.strftime('%X')}")
print(end-start)
if __name__ == '__main__':
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment