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-ready — asyncio.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.url           # document URL after redirects and script navigation
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

macOS: harmless OpenGL warning

macOS users may see a harmless GLD_TEXTURE_INDEX_2D is unloadable… line on stderr. Applications can redirect file descriptor 2 themselves if needed.

Metadata

Release files for servo-fetch 0.15.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for servo-fetch 0.15.2
File Size Uploaded Provenance Actions
servo_fetch-0.15.2.tar.gz 241.4 kB With provenance Details for servo_fetch-0.15.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for servo-fetch 0.15.2
File Actions
servo_fetch-0.15.2-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for servo_fetch-0.15.2-cp311-abi3-win_amd64.whl
servo_fetch-0.15.2-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details for servo_fetch-0.15.2-cp311-abi3-manylinux_2_28_x86_64.whl
servo_fetch-0.15.2-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details for servo_fetch-0.15.2-cp311-abi3-manylinux_2_28_aarch64.whl
servo_fetch-0.15.2-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for servo_fetch-0.15.2-cp311-abi3-macosx_11_0_arm64.whl
servo_fetch-0.15.2-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for servo_fetch-0.15.2-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 174.9 MB

Release files / servo_fetch-0.15.2.tar.gz

Download URL servo_fetch-0.15.2.tar.gz
Size 241.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bd0cde982e3ae6687de2131120f25cfbca6d31daab498def5b0c44ce97c06307
BLAKE2b-256 checksum
How to use checksums
c27db40c40b9a7aed422132deb17b8a60f99f5f7cfd570d1cfad7bbed5003ff4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / servo_fetch-0.15.2-cp311-abi3-win_amd64.whl

Download URL servo_fetch-0.15.2-cp311-abi3-win_amd64.whl
Size 33.8 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9c762630113300f16dfcdcd679c7c3f36cce7e49347762021dc5f3b8f9c8febb
BLAKE2b-256 checksum
How to use checksums
bb40ad226c06f188ce1dba723e000a5f52ca17be0a3440bf531170133431c0cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / servo_fetch-0.15.2-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL servo_fetch-0.15.2-cp311-abi3-manylinux_2_28_x86_64.whl
Size 38.0 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
29eb9bfea210bc772e3ace3ee4c5c69c0ed5a851bb54284d35a2e4fea1feb965
BLAKE2b-256 checksum
How to use checksums
b66640dfa163096e7ceeff379b44d32bc0b557b70b0b2002ffbbb7c98ee69095
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / servo_fetch-0.15.2-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL servo_fetch-0.15.2-cp311-abi3-manylinux_2_28_aarch64.whl
Size 36.7 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
c5b2d0612817e6ddfd0917344b0afecf918c8f6fe56c339c9e35dce3850cf3e2
BLAKE2b-256 checksum
How to use checksums
022afb7ae99e9a33db3ae7743b24daac819aa4b32403a4559d1d4c83f451474b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / servo_fetch-0.15.2-cp311-abi3-macosx_11_0_arm64.whl

Download URL servo_fetch-0.15.2-cp311-abi3-macosx_11_0_arm64.whl
Size 32.1 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
91541a99ca8ec8effe54d7223d8d104ac5abec0f55eef0ad1895347331c25bda
BLAKE2b-256 checksum
How to use checksums
1246209a511a3dd658d64bc5772ecac3693c970b5e68823574a48e9d7e70a272
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / servo_fetch-0.15.2-cp311-abi3-macosx_10_12_x86_64.whl

Download URL servo_fetch-0.15.2-cp311-abi3-macosx_10_12_x86_64.whl
Size 34.2 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d170c19aa79f4b21645b45744e5c15e09d76b84b860fa48395b45367ca5c8509
BLAKE2b-256 checksum
How to use checksums
d8fb3eb2bf12465e437cf0b421ae5b38f42e2a93938dd77d6410ff71459be024
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for servo-fetch 0.15.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for servo_fetch-0.15.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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