Skip to main content

tl-parser

CI pypi version Changelog

tl (installed as tl-parser) is a fast HTML parser for Python written in Rust.

It's a python binding library for astral-tl—a maintained fork of the original y21/tl—focused on performance, HTML selector coverage and a stable API.

Installation

Wheels for Python 3.12–3.14 are published to PyPI. Install with:

uv add tl-parser

Quickstart

import tl

dom = tl.parse('<p id="text">Hello</p>')
text = dom.get_element_by_id("text")
assert text.inner_text() == "Hello"

Finding a tag using the query selector API

import tl

dom = tl.parse('<div><img src="cool-image.png" /></div>')
matches = dom.query_selector('img[src]')

if matches:
    img = matches[0]
    print("Found:", img.outer_html())
else:
    print("No matching tag")

Iterating over the subnodes of an HTML document

import tl

dom = tl.parse('<div><img src="cool-image.png" /></div>')

for node in dom.children():
    name = node.name().unwrap_or("(text)")
    print(f"child={name} inner_text={node.inner_text()}")

Working with classes, attributes, and text

import tl

html = '<div class="a"><p class="a b" id="text">Hello</p></div>'
dom = tl.parse(html)

print([el.inner_text() for el in dom.get_elements_by_class_name("a")])
# ['Hello', 'Hello']

p = dom.get_element_by_id("text")
print(p.get_attribute("class"))
# 'a b'

Note: the binding currently exposes read-only DOM access (querying, traversing, serialization). Mutation APIs from the original crate (e.g., changing attributes) are not yet wrapped, but the underlying Rust code supports them if/when we extend the Python surface.

Benchmarks

In our benchmarks, tl-parser parses HTML around 5x faster than the next-fastest parser and is often up to 100x faster for class, ID, and CSS lookups. The chart shows median startup-adjusted time per operation, so lower bars are better. See the benchmark code for the workloads and reproduction instructions.

Python HTML parser benchmark

Contributing

To hack on the binding, let maturin compile the extension from source:

uv run maturin develop

This installs the extension module in editable mode so that import tl picks up local changes. For more background on the project and Python+Rust packaging, see my blog post "Expanding the Python universe with Rust".

License

MIT, inherited from the upstream projects. See LICENSE for details.

Metadata

Release files for tl-parser 0.7.12

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

Built distributions (wheels)

Table of built distributions (wheels) for tl-parser 0.7.12
File
tl_parser-0.7.12-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
tl_parser-0.7.12-cp314-cp314-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ x86-64 Details
tl_parser-0.7.12-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
tl_parser-0.7.12-cp314-cp314-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.12+ x86-64 Details
tl_parser-0.7.12-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
tl_parser-0.7.12-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
tl_parser-0.7.12-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
tl_parser-0.7.12-cp313-cp313-macosx_10_12_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64 Details
tl_parser-0.7.12-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
tl_parser-0.7.12-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
tl_parser-0.7.12-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
tl_parser-0.7.12-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details

Total release size: 3.1 MB

Release files / tl_parser-0.7.12-cp314-cp314-win_amd64.whl

Download URL tl_parser-0.7.12-cp314-cp314-win_amd64.whl
Size 166.6 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
9ca262567a8a9cdd0076add6f8c70032efb0a6d96898d40033c21bc46e612d97
BLAKE2b-256 checksum
How to use checksums
6c3c662188d19c5e2a676ac158483fe2609ddcded0f99777bff237d9b527727e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tl_parser-0.7.12-cp314-cp314-manylinux_2_34_x86_64.whl

Download URL tl_parser-0.7.12-cp314-cp314-manylinux_2_34_x86_64.whl
Size 310.1 kB
Tags CPython 3.14 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
d5d2c4fb318021907966f455943cb4659981a9f0f7a673297dfce3e8a831b0f8
BLAKE2b-256 checksum
How to use checksums
4514d9e76fe1459251ac78cfaab1755a2660dbc23ad7036f3b36079a0c7d76ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tl_parser-0.7.12-cp314-cp314-macosx_11_0_arm64.whl

Download URL tl_parser-0.7.12-cp314-cp314-macosx_11_0_arm64.whl
Size 272.6 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f728a8fe3ae6602dc01ad3e59f83267a9f75024ecb4600ef4d4c8b2370be7f02
BLAKE2b-256 checksum
How to use checksums
1b780a0b02f4009ee86c5237697f67961657ecfaf7641f9630311c6b246dba58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tl_parser-0.7.12-cp314-cp314-macosx_10_12_x86_64.whl

Download URL tl_parser-0.7.12-cp314-cp314-macosx_10_12_x86_64.whl
Size 276.6 kB
Tags CPython 3.14 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3ec36df0ab32b15c2b72c2f77589beeb8c7180dd0743999132c96c0c6ba349e0
BLAKE2b-256 checksum
How to use checksums
53137c3c466871b7c7e0ecdd58fc5884878335f5f6630c40685cc6ee4a5a8581
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tl_parser-0.7.12-cp313-cp313-win_amd64.whl

Download URL tl_parser-0.7.12-cp313-cp313-win_amd64.whl
Size 166.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
e1f27faf24e294111da68c25065985f8f03f56964da15be7551c3db3aa1bc26d
BLAKE2b-256 checksum
How to use checksums
34d74428826f357aaedc6febcba8f78996d9ba9b81863c4fe36186e72da8e04d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tl_parser-0.7.12-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL tl_parser-0.7.12-cp313-cp313-manylinux_2_34_x86_64.whl
Size 310.7 kB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
232265fa4fa11a2ed0119c7ef484523010bfd3fcbf93a5e7c3bf8253aa0c386c
BLAKE2b-256 checksum
How to use checksums
b3d24a880bd7a54ec20f02ac29f8808c6ececd380b9761ce91f5eaf04937df42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tl_parser-0.7.12-cp313-cp313-macosx_11_0_arm64.whl

Download URL tl_parser-0.7.12-cp313-cp313-macosx_11_0_arm64.whl
Size 273.5 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4d4039bc43625e0d57d22ba1782e73fc4ec25da8ce6b5a88c85575c7e9f9575d
BLAKE2b-256 checksum
How to use checksums
12d2b66267eeef20aff09af20f635fa844c80fa2267df70d8e0f6ea2d43dc9f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tl_parser-0.7.12-cp313-cp313-macosx_10_12_x86_64.whl

Download URL tl_parser-0.7.12-cp313-cp313-macosx_10_12_x86_64.whl
Size 276.6 kB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
5888942eabd58985153710f573aee2e055bc663e49e5ba33535283057ddc751e
BLAKE2b-256 checksum
How to use checksums
df4404fd4160563451c884077095dd876fb774e501d885c693f5eeff406eb264
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tl_parser-0.7.12-cp312-cp312-win_amd64.whl

Download URL tl_parser-0.7.12-cp312-cp312-win_amd64.whl
Size 166.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
56b2e38709d830302a64f7b6e256f11ab02f13115d1133609b8c24a027caefaf
BLAKE2b-256 checksum
How to use checksums
4ad4191fabd8e0a19a4782011ab9603afce78d44d5e102cf2768049e8c9326fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tl_parser-0.7.12-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL tl_parser-0.7.12-cp312-cp312-manylinux_2_34_x86_64.whl
Size 310.5 kB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
17310652181c70e4de51d59fbd98811f901c34a00c4626ed5612d42db6258de8
BLAKE2b-256 checksum
How to use checksums
64e03850d3432c723b3ae2e25680a578e0db5e1f7f52355b02ef205b4f269c64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tl_parser-0.7.12-cp312-cp312-macosx_11_0_arm64.whl

Download URL tl_parser-0.7.12-cp312-cp312-macosx_11_0_arm64.whl
Size 273.0 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ed9a89a18c2a3b84083afc697e1ae0c1ae7225da51e7e8d6b700d62a2c96b1cd
BLAKE2b-256 checksum
How to use checksums
bc48b294bc2d48ad09df8518b4195ec9f4ca79bebd1c960132a5a829fd588682
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tl_parser-0.7.12-cp312-cp312-macosx_10_12_x86_64.whl

Download URL tl_parser-0.7.12-cp312-cp312-macosx_10_12_x86_64.whl
Size 276.5 kB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ea952df1c3de24a126ad10397825456fca19cc404490723faba5cde3d30bf970
BLAKE2b-256 checksum
How to use checksums
5a0834e6ffec11e068d43352663c508e41078e1905d2dffaffb38fec567eae57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for tl-parser 0.7.12

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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