Skip to main content

Parser for mhtml files

Project description

pimht

Python mhtml parser

Installation

$ pip install pimht

Example

import pimht

mhtml = pimht.from_filename("test.mhtml")
for part in mhtml:
    print(part.content_type, len(part.raw))

Modifying

import pimht

mhtml = pimht.from_filename("test.mhtml")
for part in mhtml.parts:
    if part.is_text:
        part.text = part.text.replace("Hello", "Goodbye")

with open("modified.mhtml", "wb") as f:
    f.write(mhtml.to_bytes())

Performance

The chardet module, used by default, is slow. Performance can be improved by also installing cchardet and pybase64 with:

$ pip install pimht[speedups]

This is aimed specifically at parsing Google Chrome generated snapshots as fast as possible, but feel free to report issues with MHTML files from other sources.

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

pimht-0.5.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

pimht-0.5.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file pimht-0.5.0.tar.gz.

File metadata

  • Download URL: pimht-0.5.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pimht-0.5.0.tar.gz
Algorithm Hash digest
SHA256 16355eb4328f3c678b9d2210189c41a605328af8366683e9041f627c3c8159ea
MD5 6b45fe8015de073f07623719a5fb6f5c
BLAKE2b-256 19406371a31a3e38240c3cb9ac85171684426a030eff3278e5a1b2f162a4ef22

See more details on using hashes here.

Provenance

The following attestation bundles were made for pimht-0.5.0.tar.gz:

Publisher: publish-to-pypi.yml on pilate/pimht

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pimht-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pimht-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pimht-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4beb7761474c15d6ee60b643943bac3112b73357601febe88d75c70cd06f715c
MD5 ac29e86c8ec56d47d29275f2095c57c0
BLAKE2b-256 410e00235cc91ee885b05afe3ac8ed699871ae8764b33751d21912b457e88eab

See more details on using hashes here.

Provenance

The following attestation bundles were made for pimht-0.5.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on pilate/pimht

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