Skip to main content

Browser engine in a library — fetch, render, and extract web content.

Project description

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

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.

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              # create venv + install dev deps
uv run maturin develop           # build extension (debug, fast compile)
uv run pytest                    # run tests
uv run ruff check python tests   # lint
uv run 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

Project details


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.12.2.tar.gz (186.3 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.12.2-cp310-abi3-win_amd64.whl (33.2 MB view details)

Uploaded CPython 3.10+Windows x86-64

servo_fetch-0.12.2-cp310-abi3-manylinux_2_28_x86_64.whl (37.5 MB view details)

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

servo_fetch-0.12.2-cp310-abi3-manylinux_2_28_aarch64.whl (36.6 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

servo_fetch-0.12.2-cp310-abi3-macosx_11_0_arm64.whl (32.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

servo_fetch-0.12.2-cp310-abi3-macosx_10_12_x86_64.whl (33.9 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: servo_fetch-0.12.2.tar.gz
  • Upload date:
  • Size: 186.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for servo_fetch-0.12.2.tar.gz
Algorithm Hash digest
SHA256 7ad06f176c55fcf1f6919c99af08b98fba5580dd37ce0bf19963ea6ec0d51885
MD5 961d638cb66e0a9de21077dd4b43094a
BLAKE2b-256 9e92161dcd24af563eeb59f83ad836462f3533e1e6a7cd97700be36e1e97de09

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.12.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.12.2-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: servo_fetch-0.12.2-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 33.2 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for servo_fetch-0.12.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0a87c17191cf2e666b31cf3bfe35ebf2906f0896dffda815be18f9645ef97cd3
MD5 fb540144519ba93fae3e7b3d15bf18df
BLAKE2b-256 4acb6cd8ccc3b0307936149d9b4021a11e127cdb6ea059cc217d23d4bb3ab159

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.12.2-cp310-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.12.2-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.12.2-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6206b58f44e5bfdf4a20d5eff7a4c45f442688c07e7655560a63868fd66bc666
MD5 b8db6dbe8ac20e1bba355ac51185b8b0
BLAKE2b-256 38567d75a1c5c8b3e484c921ba89aac4172ae402469520af65f164693f83b689

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.12.2-cp310-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.12.2-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.12.2-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f94f0ee80d4afba0c4163d95bb3b58181b4cbb82b087d8e5229702f0527e9cff
MD5 4aa9a6802bbf9d326b5f01130a59164a
BLAKE2b-256 41433b0c082384466a08b5555eef9218c222959a3fe4d463670aeda3c4243ef6

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.12.2-cp310-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.12.2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.12.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9cef421d19a89b4d276a7f1b43b8584cdb5c8ad32ad17ab68bf81b5b7ae0449
MD5 0bd601d0ec866f8d03155a3b58150632
BLAKE2b-256 64170569a56a36e7711e32fec732ff7e10499674178dbdeb3b691d36c706dfa9

See more details on using hashes here.

Provenance

The following attestation bundles were made for servo_fetch-0.12.2-cp310-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.12.2-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for servo_fetch-0.12.2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ed3d1ce7313460d440731e27045800f3d1bc7e38b4aef5d8371830d3b932cbf6
MD5 d2a1dc5f6d518f74ed31302d05593c8d
BLAKE2b-256 a3d69c494ce826c42b042140eede86b96e58c5e866c00639ef9dd4070cc8d0b5

See more details on using hashes here.

Provenance

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page