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.1.tar.gz (224.8 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.1-cp311-abi3-win_amd64.whl (34.1 MB view details)

Uploaded CPython 3.11+Windows x86-64

servo_fetch-0.14.1-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.1-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.1-cp311-abi3-macosx_11_0_arm64.whl (32.8 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

servo_fetch-0.14.1-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.1.tar.gz.

File metadata

  • Download URL: servo_fetch-0.14.1.tar.gz
  • Upload date:
  • Size: 224.8 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.1.tar.gz
Algorithm Hash digest
SHA256 23284d90c4ab7f2fcb33ab71c92fe95d523a12a7fb92e6a0c89de53a0ffd7654
MD5 34ef83e53cba1c8a2f2bb0a131856523
BLAKE2b-256 31eb77645dcdb714d9050d5bd998a18ba9e4c20a2131811e8c5f37acb074fedd

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.1.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.1-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: servo_fetch-0.14.1-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.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e0fff4cc80e491cc2302e13693d32336ff0f9f9761657b1d5233d08c557f4664
MD5 e69486c50fe4d5e3aa857e1510581a74
BLAKE2b-256 f144302b535dc920abff05369466e1dca1aebb7a707a54a7f7aa3ea010f08121

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.1-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.1-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.14.1-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b78c3cc28066aada7916bbe4238d9225e207ab54d48780a5674d25f95afe5482
MD5 06e6b48275d16c651c6ac1eff84acb4f
BLAKE2b-256 14e3d430662bcc40282b961bf975f8da07b1578157f5555badea52a74e6b8d1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.1-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.1-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.14.1-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b5646472432934ec71f63c2b3cf8ae63515f0a3cec77f28249477e6b7618f8d9
MD5 5888d453356fc7a956ae1a9f3e7bb950
BLAKE2b-256 51788cdd3d1b433478044cb314d2a88b96ef1104bda5ef9e47905aea8f84a19c

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.1-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.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.14.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ecd8f796bd66cf54e207d88a4a108ba14b63ff94f84dc364f96be2e759f92f02
MD5 8a092769ca004bb66a7bd33cbbbfdc2b
BLAKE2b-256 86ee5b822bf93812289bcb149cf76616596432c45adde52929e8a9ce24922ef0

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.1-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.1-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.14.1-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e4f489fe78b942774404631a66cfbb7213e3b586c5474a19b5aa2f6893ce7d93
MD5 235d6f8c17ff9322cb1e3b6e759e24b1
BLAKE2b-256 e895d8042b86067d2f0a1804f90432d4c31aab0ec3f943f66efb6c62f91fc166

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.14.1-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

0.14.2

6 files

This release

0.14.1 This release

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