Wait for the page in Python with requests
A page that paints late gets captured before it exists. settle holds the render after load, and waitFor names an element the page must actually show before the capture.
Both knobs ride the same JSON body as the url. settle is a plain hold in milliseconds after the page loads; waitFor goes further and blocks until a css selector matches, capped at ten seconds or the settle budget, whichever is smaller. A selector that never matches fails the render rather than shipping a half-painted page, so pick something the page reliably shows: this recipe waits for a paragraph.
The recipe
import requests
from pathlib import Path
ORIGIN = "https://webcapture.io"
receipt = requests.post(
f"{ORIGIN}/v1/convert",
headers={"Authorization": "Bearer wc_your_key", "Content-Type": "application/json"},
json={"url": "https://example.com/", "settle": 1500, "waitFor": "p"},
timeout=60,
).json()
# the download url names /v1/conversions/<id>.pdf at the serving origin
pdf = requests.get(
receipt["download"],
headers={"Authorization": "Bearer wc_your_key"},
timeout=60,
)
pdf.raise_for_status()
Path("page.pdf").write_bytes(pdf.content)
settle takes 0 to 10000 milliseconds and replaces the endpoint's own default hold; waitFor takes a selector of 1 to 500 characters validated by Chromium. The two compose: the selector wait runs first, the settle hold runs on top of it, and both sit inside the same render budget the 60 second client timeout already covers. A late chart, a web font, or a client-side table is what these two fields are for.
Same-key GET: 401 without it; 404 for another key.
The fields this recipe uses
settle: milliseconds to hold after the page loads before the capture, 0 to 10000; absent keeps the endpoint's default (350).waitFor: a css selector, 1 to 500 characters, the render waits for after load, capped at min(settle, 10 seconds); a selector that never matches fails the render.
Related
- Next: Get a free key to run this Python recipe, or read the API docs.
- More recipes: Python: convert from a URL, Node: poll an async render, TypeScript: dark mode.
- The webcapture API reference: every field the convert endpoint admits, with the response shapes and the error table.
- The recipes hub: the same endpoint in the other languages.
- Going deeper: the formatting guide explains why late-painting pages print early, and what each wait mode fixes.
- The free URL to PDF tool: try the render in a browser before you wire the call.
Method
Source: convert field reference, checked 2026-10-05. Corrections.