Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- import aiohttp
- import time
- import requests
- async def parse(url):
- with aiohttp.ClientSession() as session:
- async with session.get(url) as resp:
- main.append(await resp.text())
- main = []
- t1 = time.time()
- loop = asyncio.get_event_loop()
- f = asyncio.wait([parse('https://yandex.ru/search/?text={}'.format(i)) for i in range(100)])
- loop.run_until_complete(f)
- print(time.time() - t1)
- loop.close()
- def req(url):
- a = requests.get(url)
- main2.append(a.text)
- main2 = []
- t1 = time.time()
- for i in range(100):
- req('https://yandex.ru/search/?text={}'.format(i))
- print(time.time() - t1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement