Created
November 4, 2019 10:49
-
-
Save 0xsha/9bb8e69b513027119e66ce520782eb2c to your computer and use it in GitHub Desktop.
This file contains 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
# 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