How to use Colab to scrape images from a website with Python? or Best way to scrape images from a web

16 Replies, 1350 Views

Honestly, I gave up on BeautifulSoup for dynamic sites. Now I just use `playwright` in Colab. It's like Selenium but faster and less buggy.

For colab scrape images from website python:

```python
!pip install playwright
import playwright.sync_api

with playwright.sync_api.sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("your_url")
imgs = page.query_selector_all('img')
for img in imgs:
print(img.get_attribute('src'))
```

Works every time, even with infinite scroll pages!

Messages In This Thread



Users browsing this thread: 1 Guest(s)