Examples
A basic example in browser automation is adding a small, realistic pause after navigation before clicking the next element.
import random
import time
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("https://example.com")
dwell_time = random.uniform(2.0, 5.5)
time.sleep(dwell_time)
print(f"Stayed on page for {dwell_time:.2f} seconds")
browser.close()
If you're calling a scraping API with browser actions, dwell time is often the wait between steps, not just a blind fixed sleep.
{
"url": "https://example.com/product/123",
"browser": true,
"actions": [
{"type": "wait_for", "selector": "h1"},
{"type": "wait", "ms": 3200},
{"type": "click", "selector": "button.show-more"}
]
}
Practical tips
- Don’t treat dwell time as a magic anti-bot trick: fixed 3-second sleeps everywhere just make jobs slower and still look fake.
- Prefer event-based waiting over arbitrary waiting: wait for a selector, API response, DOM change, or network idle when possible.
- Add variance when you do need pauses: real browsing patterns are uneven, not perfectly spaced.
- Keep the page type in mind: search results, product pages, and infinite scroll feeds all have different natural timings.
- Measure the cost: extra dwell time across thousands of pages turns into real runtime and proxy spend fast.
- If a target is sensitive, combine dwell time with other things that matter more: good fingerprinting, sane concurrency, session continuity, and IP quality.
- In production, the question is usually not "can we wait longer" but "what is the minimum wait that keeps extraction stable."
Use cases
- Search and SEO analysis: estimating whether users actually engaged with a result or bounced right back.
- Browser automation for scraping: spacing interactions so a workflow behaves more like an actual session.
- Dynamic page extraction: giving client-side content, lazy-loaded elements, or anti-bot challenges time to settle before extraction.
- Session simulation: keeping a login or browsing flow from looking absurdly fast.
- Router-based scraping setups: if you use ScrapeRouter with browser rendering, dwell time is one of the small control knobs you may use, but it works best alongside retries, provider routing, and proper wait conditions.