What's the best way to Web scrape images from HTML? or How can I Web scrape images from HTML efficien

22 Replies, 721 Views

Don’t forget to respect `srcset` attributes when you Web scrape images from HTML! Sites use it for responsive images, so you might miss higher-res versions if you only check `src`.

Here’s how to grab both in BeautifulSoup:

```python
for img in soup.find_all('img'):
print(img.get('src') or img.get('srcset'))
```

Messages In This Thread



Users browsing this thread: 1 Guest(s)