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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tl_parser-0.7.12-cp314-cp314-win_amd64.whl (166.6 kB view details)

Uploaded CPython 3.14Windows x86-64

tl_parser-0.7.12-cp314-cp314-manylinux_2_34_x86_64.whl (310.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

tl_parser-0.7.12-cp314-cp314-macosx_11_0_arm64.whl (272.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

tl_parser-0.7.12-cp314-cp314-macosx_10_12_x86_64.whl (276.6 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

tl_parser-0.7.12-cp313-cp313-win_amd64.whl (166.6 kB view details)

Uploaded CPython 3.13Windows x86-64

tl_parser-0.7.12-cp313-cp313-manylinux_2_34_x86_64.whl (310.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

tl_parser-0.7.12-cp313-cp313-macosx_11_0_arm64.whl (273.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

tl_parser-0.7.12-cp313-cp313-macosx_10_12_x86_64.whl (276.6 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

tl_parser-0.7.12-cp312-cp312-win_amd64.whl (166.6 kB view details)

Uploaded CPython 3.12Windows x86-64

tl_parser-0.7.12-cp312-cp312-manylinux_2_34_x86_64.whl (310.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

tl_parser-0.7.12-cp312-cp312-macosx_11_0_arm64.whl (273.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

tl_parser-0.7.12-cp312-cp312-macosx_10_12_x86_64.whl (276.5 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file tl_parser-0.7.12-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 166.6 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 9ca262567a8a9cdd0076add6f8c70032efb0a6d96898d40033c21bc46e612d97
MD5 940df27bb1979aa15bc0da43267c6ead
BLAKE2b-256 6c3c662188d19c5e2a676ac158483fe2609ddcded0f99777bff237d9b527727e

See more details on using hashes here.

File details

Details for the file tl_parser-0.7.12-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp314-cp314-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 310.1 kB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ x86-64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d5d2c4fb318021907966f455943cb4659981a9f0f7a673297dfce3e8a831b0f8
MD5 d83d19b15ec7b43a4881aa87902c2860
BLAKE2b-256 4514d9e76fe1459251ac78cfaab1755a2660dbc23ad7036f3b36079a0c7d76ab

See more details on using hashes here.

File details

Details for the file tl_parser-0.7.12-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp314-cp314-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 272.6 kB
  • Tags: CPython 3.14, macOS 11.0+ ARM64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f728a8fe3ae6602dc01ad3e59f83267a9f75024ecb4600ef4d4c8b2370be7f02
MD5 489651e0fe355fd627c78d303f414fbb
BLAKE2b-256 1b780a0b02f4009ee86c5237697f67961657ecfaf7641f9630311c6b246dba58

See more details on using hashes here.

File details

Details for the file tl_parser-0.7.12-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp314-cp314-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 276.6 kB
  • Tags: CPython 3.14, macOS 10.12+ x86-64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3ec36df0ab32b15c2b72c2f77589beeb8c7180dd0743999132c96c0c6ba349e0
MD5 e5dfcac6dec34bb0ade2912b077cc7f5
BLAKE2b-256 53137c3c466871b7c7e0ecdd58fc5884878335f5f6630c40685cc6ee4a5a8581

See more details on using hashes here.

File details

Details for the file tl_parser-0.7.12-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 166.6 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e1f27faf24e294111da68c25065985f8f03f56964da15be7551c3db3aa1bc26d
MD5 8586cc2bf95f94210aa0856089720dc1
BLAKE2b-256 34d74428826f357aaedc6febcba8f78996d9ba9b81863c4fe36186e72da8e04d

See more details on using hashes here.

File details

Details for the file tl_parser-0.7.12-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp313-cp313-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 310.7 kB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 232265fa4fa11a2ed0119c7ef484523010bfd3fcbf93a5e7c3bf8253aa0c386c
MD5 fb86906602f0e0393b70e6bbe19156d4
BLAKE2b-256 b3d24a880bd7a54ec20f02ac29f8808c6ececd380b9761ce91f5eaf04937df42

See more details on using hashes here.

File details

Details for the file tl_parser-0.7.12-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 273.5 kB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4d4039bc43625e0d57d22ba1782e73fc4ec25da8ce6b5a88c85575c7e9f9575d
MD5 634d1e356faa00133b9f7caa2107eade
BLAKE2b-256 12d2b66267eeef20aff09af20f635fa844c80fa2267df70d8e0f6ea2d43dc9f5

See more details on using hashes here.

File details

Details for the file tl_parser-0.7.12-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp313-cp313-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 276.6 kB
  • Tags: CPython 3.13, macOS 10.12+ x86-64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5888942eabd58985153710f573aee2e055bc663e49e5ba33535283057ddc751e
MD5 de4d9cb7952130bdaf07cb9a07d3842b
BLAKE2b-256 df4404fd4160563451c884077095dd876fb774e501d885c693f5eeff406eb264

See more details on using hashes here.

File details

Details for the file tl_parser-0.7.12-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 166.6 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 56b2e38709d830302a64f7b6e256f11ab02f13115d1133609b8c24a027caefaf
MD5 ea67e980852c2dc79265e7ce40b16ff7
BLAKE2b-256 4ad4191fabd8e0a19a4782011ab9603afce78d44d5e102cf2768049e8c9326fc

See more details on using hashes here.

File details

Details for the file tl_parser-0.7.12-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp312-cp312-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 310.5 kB
  • Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 17310652181c70e4de51d59fbd98811f901c34a00c4626ed5612d42db6258de8
MD5 904493ed7c0a4d2459051e62c52b4beb
BLAKE2b-256 64e03850d3432c723b3ae2e25680a578e0db5e1f7f52355b02ef205b4f269c64

See more details on using hashes here.

File details

Details for the file tl_parser-0.7.12-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 273.0 kB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed9a89a18c2a3b84083afc697e1ae0c1ae7225da51e7e8d6b700d62a2c96b1cd
MD5 7cea4dc90a751fb4173cb2ac4d883b08
BLAKE2b-256 bc48b294bc2d48ad09df8518b4195ec9f4ca79bebd1c960132a5a829fd588682

See more details on using hashes here.

File details

Details for the file tl_parser-0.7.12-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: tl_parser-0.7.12-cp312-cp312-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 276.5 kB
  • Tags: CPython 3.12, macOS 10.12+ x86-64
  • Uploaded using 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}

File hashes

Hashes for tl_parser-0.7.12-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ea952df1c3de24a126ad10397825456fca19cc404490723faba5cde3d30bf970
MD5 971e0b0b711e49e6d58fa28afe69fe44
BLAKE2b-256 5a0834e6ffec11e068d43352663c508e41078e1905d2dffaffb38fec567eae57

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.7.12 This release

12 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