Skip to content

Capture screenshots

Goal: capture a PNG of a rendered page, optionally faster by blocking heavy resources.

Screenshots require a browser tier (standard or stealth). Enable include_screenshot in artifact_options.

Minimal example

from scrapenest import ScrapeNestClient

client = ScrapeNestClient(api_key="sn_live_...", base_url="https://api.scrapenest.com")

result = client.scrape_sync(
    job_type="standard",
    target_url="https://example.com",
    artifact_options={"include_screenshot": True},
)
curl -X POST "https://api.scrapenest.com/api/v1/jobs" \
  -H "X-API-Key: sn_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "job_type": "standard",
    "target_url": "https://example.com",
    "artifact_options": {"include_screenshot": true}
  }'

Download the image

job = client.jobs.get(result.job_id)
shot = next(a for a in job.artifacts if a.artifact_type == "screenshot")

with open("page.png", "wb") as f:
    f.write(client.artifacts.download_bytes(shot.artifact_id))

Variations

Faster, cheaper captures — block resources you don't need in the image. Blocking images/fonts/media can cut load time dramatically:

client.scrape_sync(
    job_type="standard",
    target_url="https://example.com",
    artifact_options={
        "include_screenshot": True,
        "block_media": True,
        "block_fonts": True,
    },
)

Control the frame — set a viewport for consistent dimensions (e.g. mobile vs desktop):

client.scrape_sync(
    job_type="standard",
    target_url="https://example.com",
    viewport={"width": 390, "height": 844},   # mobile
    artifact_options={"include_screenshot": True},
)

Wait for content — for slow pages, wait until the network is idle before capturing:

client.scrape_sync(
    job_type="standard",
    target_url="https://example.com/app",
    wait_until="networkidle",
    artifact_options={"include_screenshot": True},
)

Disable auto-scroll — by default we scroll the page to trigger lazy-loaded content before capture. Set no_scroll to capture the initial viewport only:

artifact_options={"include_screenshot": True, "no_scroll": True}

See also