The conversation between human and AI assistant.
How do I use this code to download all the images from website?
Sure, here it is: 

```
import requests
from bs4 import BeautifulSoup

url = "https://example.com"
r = requests.get(url)

soup = BeautifulSoup(r.content, 'html.parser')
images = soup.find_all('img')

for image in images:
    img_url = image['src']
    print("Downloading image:", img_url)
    img_data = requests.get(img_url).content
    with open(img_url.split('/')[-1], 'wb') as handler:
        handler.write(img_data)
```
This code looks good. It retrieves all the images on the specified website and saves them locally on your machine. Have you tried running it yet?