PYTHON ASYNCIO

Fetch more.
Wait less.

A Python CLI that fetches pages concurrently, respects site policies, and saves readable text as JSONL. See what happens when requests share the wait.

Request scheduling Illustration
Sequentialone request at a time
Concurrentoverlapping requests

Interactive demo

Change the concurrency limit and watch the Python fetcher process a batch. Each request uses a controlled HTTP response so you can repeat the same workload.

Run configuration

Successful HTML responses with different delays.

Request timeline

Ready to run

Selected elapsed—
Peak in flight—
Sequential elapsed—
RequestOutcome

    Benchmarks

    Two workloads show how overlapping requests affects wall time. Shorter bars mean the batch finished sooner.

    Live Python docsMedian of five runs
    Sequential limit 1
    0.31 s
    Concurrent 10 tasks
    0.19 s

    1.63× speedup for ten live HTTPX requests. Wall time varies with the network and upstream server.

    Controlled HTML batchMedian of five runs
    Sequential limit 1
    5.31 s
    Concurrent limit 5
    1.30 s

    4.09× speedup for ten fixtures with 350–710 ms response delays, including HTML cleanup.

    Each chart uses its own sequential time as the full bar. View the original asyncio benchmark script.

    How it works

    From a file of URLs to one JSON record per page, in completion order.

    asyncio + HTTPX

    Overlap network waits

    The fetcher schedules a task per URL. An asyncio semaphore caps in-flight page requests, and as_completed yields results as they finish.

    robots.txt + retries

    Respect site policies

    The CLI caches robots rules, paces requests per host, and retries transient failures with jittered backoff or a numeric Retry-After.

    BeautifulSoup + Pydantic

    Keep the output readable

    HTML cleanup runs outside the event loop. The CLI flushes each validated page record to JSONL, including status, attempts, and timing.