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

Uploaded CPython 3.10+Windows x86-64

servo_fetch-0.12.1-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.1-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.1-cp310-abi3-macosx_11_0_arm64.whl (32.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

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

File metadata

  • Download URL: servo_fetch-0.12.1.tar.gz
  • Upload date:
  • Size: 186.0 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.1.tar.gz
Algorithm Hash digest
SHA256 f945934a1c21bbeed7ccd78bce112f86a6e4fe2b0eca39d836e444a56b374f6e
MD5 d14a7333ab7ae179a81e0f4564c46d2c
BLAKE2b-256 1bb9f557ef22928130945199dc31710f389fb908447147795bb20a49f6c9b5b9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: servo_fetch-0.12.1-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.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6dfe41aa03d871a37fd55d34270799c9360e8bb3f363502b3581614346311997
MD5 9efd546de7977ac2e30ff451966e1bf4
BLAKE2b-256 f00ca08c1252ed148ad5388a3411b67eb12e13ff7b72dac7002ef130c6d52a30

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for servo_fetch-0.12.1-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 548cb7aeb15eb26cb36f2f2ce70590a7cf2946e3f572447db8fc9f5b211467ad
MD5 8411928b681ff5a5def7501fc8447af6
BLAKE2b-256 089028bbe9698c319dfb8ddb7bf2b63f96f1ede17d193c317eda36fe3159a56f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for servo_fetch-0.12.1-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7ef9fa0912d25a10f0794a6e1e39d4bbfa356f19f7d2994b7f6672a502d04427
MD5 5b9bdd2bb43b2b4a158213a457eb167f
BLAKE2b-256 31bcb986dc543e404f90e0c922e8041cdff4775fb207f4880f0609b4e4821e4e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for servo_fetch-0.12.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 daeccf16e34b72e0676385a684c1942d96b5d2c5a23313b3606dc91c478b5beb
MD5 5e7de5fb6fde197d0f65b974d2d68703
BLAKE2b-256 13e4446db9f15d995c732ee2f0135daf1267c3cd8244abdcbf0c8ce795d6fb75

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for servo_fetch-0.12.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f20c324d537160fbecb9800f97e2157747f7184a92f4faa4e9ca4e57043888e4
MD5 7f43d7ae854dc8bd9ea014cf7cf716a2
BLAKE2b-256 f2ec5bb960ddb62b4ab097f5159319a61b47f9a7a1ca7b4e2fe9581e1f3f8c03

See more details on using hashes here.

Provenance

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