BeautifulSoup: How to Get Src of Image

Syntax:

image['src']

Example: Getting Src of an image

from bs4 import BeautifulSoup

#html source
html = """
<div>
<h1>Hello BeautifulSoup</h1>
<img src="img_girl.jpg" alt="Girl in a jacket"> 
<img src="img_boy.jpg" alt="boy in a jacket"> 
<img src="img_mom.jpg" alt="mom in a jacket"> 
<div>
"""
#BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')

#find all images
all_imgs = soup.find_all('img', src=True)

#print image url
for image in all_imgs:
      print(image['src'])

Output:

img_girl.jpg
img_boy.jpg
img_mom.jpg