servo-fetch
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_threadwrappers,AsyncClientwith streaming crawl - Typed — full
.pyistubs, 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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| servo_fetch-0.15.1.tar.gz | 239.5 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| servo_fetch-0.15.1-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| servo_fetch-0.15.1-cp311-abi3-manylinux_2_28_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| servo_fetch-0.15.1-cp311-abi3-manylinux_2_28_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| servo_fetch-0.15.1-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
| servo_fetch-0.15.1-cp311-abi3-macosx_10_12_x86_64.whl | CPython 3.11 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 178.5 MB
Release files / servo_fetch-0.15.1.tar.gz
| Download URL | servo_fetch-0.15.1.tar.gz |
|---|---|
| Size | 239.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0aa462b27be69346e77089545846f626da5ed2c035604413758a2e8d72167401
|
|
BLAKE2b-256 checksum How to use checksums |
5d2a3c555d9430a7208416e8e82e68237af6af385cd635e1ab88f3339046cbce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 22, 2026.
Transparency logRelease files / servo_fetch-0.15.1-cp311-abi3-win_amd64.whl
| Download URL | servo_fetch-0.15.1-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 34.3 MB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d20843ab3fb0c4d84e6912fce2b25c082566902bd3920389d405676e7b7587f2
|
|
BLAKE2b-256 checksum How to use checksums |
484882d438d4ff1da15c9728bd86a17d270aef75bdb43cc380da64a9788e1a60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 22, 2026.
Transparency logRelease files / servo_fetch-0.15.1-cp311-abi3-manylinux_2_28_x86_64.whl
| Download URL | servo_fetch-0.15.1-cp311-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 38.7 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0f7ea60ee0be0c63dda7b7c21728f44b1d877e023f144c89e6a6d8174cd1d7ad
|
|
BLAKE2b-256 checksum How to use checksums |
0eb41e1db58f521dd0c21997bf26a37903ff8664bf9a7486e1b38922898b1c54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 22, 2026.
Transparency logRelease files / servo_fetch-0.15.1-cp311-abi3-manylinux_2_28_aarch64.whl
| Download URL | servo_fetch-0.15.1-cp311-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 37.5 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
cb68c9a1b42cae5c737a1a0482f9249d492e6c4df6ddd8ba178209e6cd37c480
|
|
BLAKE2b-256 checksum How to use checksums |
93f44a588a0dc76c7b10089f2799642e4004f216b550819a973a0c0966e472da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 22, 2026.
Transparency logRelease files / servo_fetch-0.15.1-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | servo_fetch-0.15.1-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 32.9 MB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c17c1141999e263726e6f097095ab6ae49236737f02e346d2827da28976d9187
|
|
BLAKE2b-256 checksum How to use checksums |
cba22973ffbf765cc04d5021937149e1766108e55a02e675458f8f2048fdd800
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 22, 2026.
Transparency logRelease files / servo_fetch-0.15.1-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | servo_fetch-0.15.1-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 34.9 MB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b83a8a3992861d453ad7fe2b83d43e3ea3b06f728f709feee3558317205dc0fc
|
|
BLAKE2b-256 checksum How to use checksums |
0f32a35f471e3ddbe81e928dd31a5b9c661445479b5ddf3c0e3ec39b711b844e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 22, 2026.
Transparency log