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.0.tar.gz (224.5 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.0-cp311-abi3-win_amd64.whl (34.2 MB view details)

Uploaded CPython 3.11+Windows x86-64

servo_fetch-0.14.0-cp311-abi3-manylinux_2_28_x86_64.whl (38.6 MB view details)

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

servo_fetch-0.14.0-cp311-abi3-manylinux_2_28_aarch64.whl (37.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

servo_fetch-0.14.0-cp311-abi3-macosx_11_0_arm64.whl (32.9 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

servo_fetch-0.14.0-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.0.tar.gz.

File metadata

  • Download URL: servo_fetch-0.14.0.tar.gz
  • Upload date:
  • Size: 224.5 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.0.tar.gz
Algorithm Hash digest
SHA256 e264843cd3c4f1db62abe040d4b9cbb062bba0dcca6e30b22ced538efb924c0e
MD5 58613616a7c348bad3fafa7005bb0fac
BLAKE2b-256 5f4e616896a7bda9e0374da85e8f581da8854fe24a9a8a753f998fb245c7de48

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: servo_fetch-0.14.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 34.2 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.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 65ae5be9b6ad633c2814545e5d45df01b525bd88d2d29c5420f0e12c2fdd9e93
MD5 ffc03acfe02e343b64a18ea0b5a0b499
BLAKE2b-256 aa5cdc7af5aca0b4b71338490ffd8266a92dd0944935127aae9d68290990dfb7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for servo_fetch-0.14.0-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fe03d9ff93fcf1d4981d6ddbefc1349fd60aa6199face3cd9126dd5987876ce3
MD5 95d6e1507fa23cb30a0e31d0acff19cd
BLAKE2b-256 5fedd032a4a6cc9c8e02f3cf526d08db8c20581505e8b07594955a3fcbd38406

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for servo_fetch-0.14.0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c7d34116c1b8ce678d38d8c424b22e751ace19699b15cc2e30a8263dd7893017
MD5 b680bb0ccdb2b438e92f8b6d989dbe6f
BLAKE2b-256 348161165f07ceebc325d7a65491f09e288df481f63223862ced1beb525a67fe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for servo_fetch-0.14.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 19af4a160d39b01f24124d5b4c34e0d5aa53ea959bcc72cf97ec3658bd12f147
MD5 fc3d15e3b0acbda6bafbdba4d2c3126e
BLAKE2b-256 3a61bf40377fe8e7de237a0db199ab00f0856b09ad5d4878ffedddecde2494f1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for servo_fetch-0.14.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0965c06cfdd262b3630bb5b65c633c3f9937d89e661df3f439161cd422fedd13
MD5 2148864d9a3522ef7fb46fac2670607e
BLAKE2b-256 33c02d8e0144b4f0c004608daecb0721ecac19f6d56b8aba46eec490cdf095a9

See more details on using hashes here.

Provenance

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

0.14.1

6 files

This release

0.14.0 This release

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