htmldammit
Make every effort to properly decode HTML, because HTML is unicode, dammit!
Features
Very easy to use with integrations for requests and urlopen().
Utilizes information from HTTP headers, inline encoding declarations, and UTF BOM-s (Byte Order Marks), as well as falling back to making a best guess based on the raw data.
Improves upon BeautifulSoup’s great UnicodeDammit utility.
Installation
pip install htmldammit
Additionally, it is highly recommended to install the cchardet and/or the chardet libraries. This will enable the fallback to guessing the encoding based on the raw data.
pip install cchardet chardet
Basic usage
To decode any binary HTML content into unicode (passing HTTP headers is optional):
from htmldammit import decode_html
html = decode_html(raw_html, http_headers)
To get unicode HTML from a requests response:
from htmldammit.integrations.requests import get_response_html
response = requests.get('http://www.example.org/')
html = get_response_html(response)
To get unicode HTML from a urlopen() response:
from htmldammit.integrations.urllib import get_response_html
response = urlopen('http://www.example.org/')
html = get_response_html(response)
Metadata
Release files for htmldammit 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| htmldammit-0.1.1.tar.gz | 5.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| htmldammit-0.1.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 14.1 kB
Release files / htmldammit-0.1.1.tar.gz
| Download URL | htmldammit-0.1.1.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f90df0fa93fc2c7898be2512ce466a0400f23741e128f61ac7c63f94c4316c21
|
|
BLAKE2b-256 checksum How to use checksums |
3e0433da2e7a32eb3d0cf00db530d1ce737dfdfe8d28678960876d7ecc18a6c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / htmldammit-0.1.1-py2.py3-none-any.whl
| Download URL | htmldammit-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e0d0e7defdb3eb753c5056ca16128c5ec0775b131ddf2b40b6d7e86f426f63b6
|
|
BLAKE2b-256 checksum How to use checksums |
9bb492f2301a16e9db56f6022981d862e9e2719a44c17d8948735257ea881569
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |