How to web scrape images from HTML using BS4?

12 Replies, 1904 Views

Hi there!

To download images after scraping the URLs, using the requests library is the way to go.

You can simply loop through the list of image URLs and use `requests.get()` to download them. Here's a basic example:

```python
import requests

for url in image_urls:
img_data = requests.get(url).content
with open('image.jpg', 'wb') as handler:
handler.write(img_data)
```

Messages In This Thread



Users browsing this thread: 1 Guest(s)