Python bindings to the ammonia HTML sanitization library.
Project description
nh3
Python bindings to the ammonia HTML sanitization library.
Installation
pip install nh3
Usage
See the documentation.
Performance
A quick benchmark showing that nh3 is about 20 times faster than the deprecated bleach package. Measured on a MacBook Air (M2, 2022).
Python 3.11.0 (main, Oct 25 2022, 16:25:24) [Clang 14.0.0 (clang-1400.0.29.102)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.9.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import requests
In [2]: import bleach
In [3]: import nh3
In [4]: html = requests.get("https://www.google.com").text
In [5]: %timeit bleach.clean(html)
2.85 ms ± 22.8 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [6]: %timeit nh3.clean(html)
138 µs ± 860 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
License
This work is released under the MIT license. A copy of the license is provided in the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nh3-0.2.17.tar.gz
(15.0 kB
view hashes)
Built Distributions
nh3-0.2.17-cp37-abi3-win_amd64.whl
(571.5 kB
view hashes)
nh3-0.2.17-cp37-abi3-win32.whl
(572.5 kB
view hashes)
Close
Hashes for nh3-0.2.17-cp37-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aa52a7def528297f256de0844e8dd680ee279e79583c76d6fa73a978186ddfb |
|
MD5 | f003b3367da19b958208cbd7daa83e7f |
|
BLAKE2b-256 | 9d52ebab65758efae7980b15cdea290f0957ac3b25df6cbc098d9747c2b02bd3 |
Close
Hashes for nh3-0.2.17-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3f55fabe29164ba6026b5ad5c3151c314d136fd67415a17660b4aaddacf1b10 |
|
MD5 | 2fb8aabaac79260caae7781fbbcf3b12 |
|
BLAKE2b-256 | 622dc9ed7cb1f3ddd0ec03dcfc1d0cb2f8d985db5c612f2150108d8aeb3a11c3 |
Close
Hashes for nh3-0.2.17-cp37-abi3-musllinux_1_2_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4427ef0d2dfdec10b641ed0bdaf17957eb625b2ec0ea9329b3d28806c153d71 |
|
MD5 | 50cbc3107feeb71df48a230680bbc2ac |
|
BLAKE2b-256 | 543f27445553120573a827a72d80acee85c7a0d2094f523469317df5c44470f8 |
Close
Hashes for nh3-0.2.17-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c790769152308421283679a142dbdb3d1c46c79c823008ecea8e8141db1a2062 |
|
MD5 | 1f33bff26132e47cc909ca279377a5dd |
|
BLAKE2b-256 | 9b3976f24bc520eb6243589c1f2ecc089ea9ee7de0ce83e5b40342522dc0c8f0 |
Close
Hashes for nh3-0.2.17-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7a25fd8c86657f5d9d576268e3b3767c5cd4f42867c9383618be8517f0f022a |
|
MD5 | 1d91ad46e53f4ba4d382e084b215ad01 |
|
BLAKE2b-256 | 40b314326a0229ae14375a22bc011e8753372d5eeed2fe415a3c120d49452ec7 |
Close
Hashes for nh3-0.2.17-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c21bac1a7245cbd88c0b0e4a420221b7bfa838a2814ee5bb924e9c2f10a1120b |
|
MD5 | 90e3c5b97abc6680f4189ba12579f25d |
|
BLAKE2b-256 | da19d52d9a0247007835df949f17abd904615248dc1b94d67cb8c99100330f08 |
Close
Hashes for nh3-0.2.17-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba73a2f8d3a1b966e9cdba7b211779ad8a2561d2dba9674b8a19ed817923f65f |
|
MD5 | e30fa06a3a88db94c94fd2d0a2579a86 |
|
BLAKE2b-256 | 254d74b3aaaa15e0ecef58f3f3337e8b681d42e20e67483aebf48cb779ead6bb |
Close
Hashes for nh3-0.2.17-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40015514022af31975c0b3bca4014634fa13cb5dc4dbcbc00570acc781316dcc |
|
MD5 | e8ec70f5cf8b3fb9adf622b7f0fb5d51 |
|
BLAKE2b-256 | c5fb49273f7b161aeeffb5b4f796a53ee50852f37bd7549843e2ed76052227ef |
Close
Hashes for nh3-0.2.17-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85cdbcca8ef10733bd31f931956f7fbb85145a4d11ab9e6742bbf44d88b7e351 |
|
MD5 | f12e1ed5bc0697d9abd0204eec070e06 |
|
BLAKE2b-256 | f0f6d21910c15d6e5beccdf12d6854d996e158a74785ec1d8c8dd053507ac771 |
Close
Hashes for nh3-0.2.17-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22c26e20acbb253a5bdd33d432a326d18508a910e4dcf9a3316179860d53345a |
|
MD5 | e387a66e155d0d6407365c9f57004177 |
|
BLAKE2b-256 | 51aea3bbe3e237245630bc2a54a87db2be6efb42e80215f4083a9361845115d7 |
Close
Hashes for nh3-0.2.17-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0316c25b76289cf23be6b66c77d3608a4fdf537b35426280032f432f14291b9a |
|
MD5 | 86a5a3ecb2bd56dc443792f877b16f37 |
|
BLAKE2b-256 | 2685b6b09ba7eefe55505bf668bafff2d578fdaff5a1c8a4613d218391b8d761 |
Close
Hashes for nh3-0.2.17-cp37-abi3-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66f17d78826096291bd264f260213d2b3905e3c7fae6dfc5337d49429f1dc9f3 |
|
MD5 | 719bb638d7bda8771a8adefe2262b6ee |
|
BLAKE2b-256 | 04c85000b81bfa6311c04d8900ae0bc27f2fc0b1c59bd34d807788f22011eda0 |
Close
Hashes for nh3-0.2.17-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c551eb2a3876e8ff2ac63dff1585236ed5dfec5ffd82216a7a174f7c5082a78a |
|
MD5 | c14a5116eedb6fb1be0828ca66efb9d9 |
|
BLAKE2b-256 | 07a19c73f4228cb4587ac95fee1652939f420a390e6bd74af61032c871e8d757 |
Close
Hashes for nh3-0.2.17-cp37-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 551672fd71d06cd828e282abdb810d1be24e1abb7ae2543a8fa36a71c1006fe9 |
|
MD5 | 29b2829723f9fe6210e46279558f5559 |
|
BLAKE2b-256 | 0f4e180c017c9fba59094478068d3743d764ead3132bc910d4619b7e58bccc3c |