async await in Python with asyncio and aiohttp

preview_player
Показать описание
Let's learn async-await, asyncio, and asynchronous programming in Python. We will also learn how to use aiohttp. This video is a great foundational video to understand async-await.

🔥 codeRECODE.com EXCLUSIVE
⮕ Become a member and get access to all the courses on my site:
⮕ Take the course on Scrapy Basics for $1 or free 😀
(Use coupon code *FREE* on checkout page)

🎥 RELATED VIDEOS

🔓 SOURCE CODE

📠 GEAR I USE and RECOMMEND
Note: These are affiliate links. I get a small commission if you click on these links and buy. This does not cost you anything.
⮕ Røde PodMic
⮕ Audio Interface - Focusrite Scarlett 2i2

📕 CHAPTERS
00:00 How sync works
00:49 Why not to sync
02:05 async step 1
03:15 It's a coroutine
04:17 Event loop
06:58 Tasks
09:42 Gather
12:02 Practical example with aiohttp

#asyncio #aiohttp #python #codeRECODE #upendra

-~-~~-~~~-~~-~-
Please watch: "Making Scrapy Playwright fast and reliable"
-~-~~-~~~-~~-~-
Рекомендации по теме
Комментарии
Автор

Requesting to add more videos on async, need more videos please!

RajbirAhmedOfficial
Автор

Thanks! for sharing this wonderful topic

hayat_soft_skills
Автор

It's really a helpful video! Thanks.

aymantareq
Автор

Love your content, learnt alot from your channel. Thank you. Keep up the good work.
.
If possible create some tutorials to run scrapers on aws and scale it too.

jagdisho
Автор

Thank you upendra for such quality content.

pranavgarg
Автор

holy sh..., great video...im creating a bot for trading but i havent understand async to now..thanks a lot Upendra.... :)

cosmicblack
Автор

If you are facing problem of ''RuntimeError: Event loop is closed'' in Windows then
Just replace this code ''asyncio.run(main())''
with

asyncio.run(main())
Especially in the async_scraper.py file, Thanks.

muhammadarqamwaheed
Автор

You mentioned, we can't use beautifulsoup with async, then what's the alternative?

Loki-vyvg
Автор

please make a video on how we can convert our scrapy project into an exe file? I tried to search on youtube but failed to find even a single video. I also go through some answers in StackOverflow but am unable to understand what is happening ...

pythonically
Автор

Sir I am facing a problem., sir can u tell me how to download a image in a website in a canvas tag with no url

mohammaduzair
Автор

I'm having trouble with your code. When I run just one url, it is fast. Two or more urls take 20 seconds or more. Can you help?

import re
import aiohttp
import asyncio
import time

start_time = time.time()

]
]

async def get_response(session, url):
async with session.get(url) as resp:
text = await resp.text()
exp = r'(<title>).*(<\/title>)'
return re.search(exp, text).group(0)


async def main():
async with aiohttp.ClientSession() as session:

tasks = []
for url in links:
tasks.append(asyncio.create_task(get_response(session, url)))

results = await asyncio.gather(*tasks)
for result in results:
print(result)



asyncio.run(main())
print("--- %s seconds ---" % (time.time() - start_time))

wdmtaj
join shbcf.ru