Skip to main content

servo-fetch

CI PyPI Python uv Ruff

Python bindings for servo-fetch — fetch, render, and extract web content with an embedded Servo browser engine.

  • No Chromium — single binary, no browser download
  • JavaScript execution — full Servo engine with SpiderMonkey
  • Schema extraction — declarative CSS-selector → structured JSON, no LLM
  • Async-readyasyncio.to_thread wrappers, AsyncClient with streaming crawl
  • Typed — full .pyi stubs, works with ty / mypy / pyright

Install

Requires Python 3.11 or later.

pip install servo-fetch

Quick Start

import servo_fetch
page = servo_fetch.fetch("https://example.com")
page.html          # rendered HTML
page.inner_text    # document.body.innerText
page.markdown      # readable Markdown (lazy, cached)
page.title         # str | None

Schema Extraction

from servo_fetch import Schema, Field

schema = Schema(
    base_selector=".product",
    fields=[
        Field(name="title", selector="h2", type="text"),
        Field(name="price", selector=".price", type="text"),
        Field(name="url", selector="a", type="attribute", attribute="href"),
    ],
)

page = servo_fetch.fetch("https://shop.example.com", schema=schema)
page.extracted  # [{"title": "...", "price": "...", "url": "..."}]

Session Cookies

To fetch authenticated pages, pass a str or os.PathLike path to a Netscape-format cookies.txt via cookies_file:

import servo_fetch

page = servo_fetch.fetch("https://app.example.com/dashboard", cookies_file="cookies.txt")

# Also accepted by Client.fetch / Client.crawl and their async equivalents.
client = servo_fetch.Client(user_agent="MyBot/1.0")
pages = client.crawl("https://app.example.com", cookies_file="cookies.txt", max_pages=20)

A missing or malformed file raises servo_fetch.CookieError. Cookies are scoped to the target's site, so out-of-scope entries in the file are ignored.

Isolated Sessions

Each Session runs in its own one-use worker process, so cookies and storage persist across fetches within the session and never leak between sessions:

import servo_fetch

with servo_fetch.Session() as session:
    session.fetch("https://example.com/login")
    page = session.fetch("https://example.com/dashboard")

# async
async with servo_fetch.AsyncSession() as session:
    page = await session.fetch("https://example.com")

Custom Headers

Pass a dict[str, str] via headers to add request headers (e.g. API tokens). Accepted by fetch, Client.fetch / Client.crawl / Client.map, and their async equivalents:

import servo_fetch

page = servo_fetch.fetch("https://api.example.com", headers={"Authorization": "Bearer TOKEN"})

Framing headers (Host, Content-Length, …) are rejected, and User-Agent / Cookie have dedicated options; invalid headers raise ValueError.

Async

from servo_fetch import fetch_async, AsyncClient

page = await fetch_async("https://example.com")

async with AsyncClient(user_agent="MyBot/1.0") as client:
    async for page in client.crawl_stream("https://docs.example.com", max_pages=50):
        print(page.url, page.title)

Develop

Requires uv.

uv sync --group all --no-install-project  # create venv + install dev deps
uv run --no-sync maturin develop          # build extension (debug, fast compile)
uv run --no-sync pytest                   # run tests
uv run --no-sync ruff check python tests  # lint
uv run --no-sync ty check python          # type check

Troubleshooting

Linux: "cannot allocate memory in static TLS block"

Servo's native extension uses large thread-local storage. On some Linux systems, set before importing:

export GLIBC_TUNABLES=glibc.rtld.optional_static_tls=16384

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

servo_fetch-0.14.2.tar.gz (224.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

servo_fetch-0.14.2-cp311-abi3-win_amd64.whl (34.1 MB view details)

Uploaded CPython 3.11+Windows x86-64

servo_fetch-0.14.2-cp311-abi3-manylinux_2_28_x86_64.whl (38.5 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

servo_fetch-0.14.2-cp311-abi3-manylinux_2_28_aarch64.whl (37.3 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

servo_fetch-0.14.2-cp311-abi3-macosx_11_0_arm64.whl (32.8 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

servo_fetch-0.14.2-cp311-abi3-macosx_10_12_x86_64.whl (34.8 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file servo_fetch-0.14.2.tar.gz.

File metadata

  • Download URL: servo_fetch-0.14.2.tar.gz
  • Upload date:
  • Size: 224.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for servo_fetch-0.14.2.tar.gz
Algorithm Hash digest
SHA256 01112e957db009ce3591064957c74ec35aa6355e6565c35e011787658a697eaf
MD5 c414d3ba9c102be0e87730d6fc7f5208
BLAKE2b-256 3e2a02c3b63bd9e8920fc280bb5f19415379e38bb5f2d02dd8532fa94e4ccbe3

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.2.tar.gz:

Publisher: release-python.yml on konippi/servo-fetch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file servo_fetch-0.14.2-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: servo_fetch-0.14.2-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 34.1 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for servo_fetch-0.14.2-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d48db23cc8fc1a714aba8af85bbfb3d3ea64fe58ecdbe9719389c9b3a6490bf9
MD5 db023781f834678ee8717880be7e7411
BLAKE2b-256 29b4132c9da206fbdd453c70691e7886f6192dc780cefb88a48520792df764ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.2-cp311-abi3-win_amd64.whl:

Publisher: release-python.yml on konippi/servo-fetch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file servo_fetch-0.14.2-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.14.2-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d4119fc9b5ed7cd9df713035b18ad37123aa46d03ea38ca7d233cc65e9c36d79
MD5 45935734a1c3b1dfb54189e945377a12
BLAKE2b-256 cf012e404c720d93fe6584a41f07cbf5d717653f2c26b841fe76ede7d92384c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.2-cp311-abi3-manylinux_2_28_x86_64.whl:

Publisher: release-python.yml on konippi/servo-fetch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file servo_fetch-0.14.2-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.14.2-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 030f92c6fb5e6f6cdb7d24999e2931937c8dc122bf1098c56327418999733404
MD5 001809526d8417e3de607e0539a5e6ee
BLAKE2b-256 6c8292d3f84e7cb493a561192adee55b33759f5426636528490e0deedcaf5200

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.2-cp311-abi3-manylinux_2_28_aarch64.whl:

Publisher: release-python.yml on konippi/servo-fetch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file servo_fetch-0.14.2-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.14.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 05a49245357ab213ad77b3d9e2ba75e28b0602b6b37b36b4e6c1f489606bdd16
MD5 3ad98027f681aaf0d564707525356dd8
BLAKE2b-256 013eaefe08b2e601cf9c544d54f23e367d126cfc6c7acc6b844f15192b546ed1

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.2-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release-python.yml on konippi/servo-fetch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file servo_fetch-0.14.2-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.14.2-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6861045ccc43d90edab1690a46a7437dc668101171e9ba0ec0d536bcb26577c7
MD5 a05940399e6c920789951d26851df7c2
BLAKE2b-256 c6fbed70c57ec0345e5a04f5dfc97f93bc9b2db067c8b80e9bb6f5b040df2518

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.2-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: release-python.yml on konippi/servo-fetch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.14.2 This release

6 files

0.14.1

6 files

0.14.0

6 files

0.13.1

6 files

0.13.0

6 files

0.12.2

6 files

0.12.1

6 files

0.12.0

6 files

0.11.4

6 files

0.11.3

6 files

0.11.2

6 files

0.11.1

6 files

0.11.0

6 files

0.10.1

6 files

0.10.0

5 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page