This folder contains a Python script that demonstrates how to use Gaffa's Site Mapping and Browser Requests APIs to automatically scrape and download every image from a website. For more information, read the accompanying blog post or the full tutorial.
- Maps the Territory: Uses Gaffa's
site/mapendpoint to find every page on the target website - Renders Each Page: Uses Gaffa's Browser Request API to capture the fully-rendered DOM (including JavaScript-loaded images)
- Finds & Downloads: Extracts all
<img>tags and downloads the images using Gaffa'sdownload_fileaction
First, make sure you have the required libraries installed and your GAFFA_API_KEY environment variable set.
Required libraries:
pip install requestsThen, run the script:
python scrape_images.py- Handles JavaScript: Modern sites load images dynamically — Gaffa renders the full page first
- Stealth & Success: Residential proxies and real browser fingerprints make requests appear as legitimate user traffic
- Responsible Caching: With
max_cache_age, repeated requests are served from cache, sparing target servers - Built-in Reliability: Automatic request pacing and retries (always respect
robots.txt) - Automatic Format Detection: Correct file extension provided in the download URL — no content-type parsing needed
For more information, see the Gaffa documentation.