Skip to main content

Extract difference between two html pages

Project description

PyPI Version Build Status Code Coverage

This package allows you to extract a difference between two html pages: given pages A and B, it will try to extract parts of A that are changed in B. It uses lxml.html.diff under the hood. but provides only changed parts as HTML.

It requires Python 3 currently.

License is MIT.

Installaton

You can install the package from PyPI:

pip install extract-html-diff

Usage

You can extract diff as text:

import extract_html_diff

html = '<div> <h1>My site</h1> <div>My content</div> </div>'
other_html = '<div> <h1>My site</h1> <div>Other content</div> </div>'

extract_html_diff.as_string(html, other_html)

this will give you:

'<div><div>My content</div>  </div>'

You can also get diff as a tree (an lxml.html.HtmlElement) if you plan to do additional transformations or change serialization:

extract_html_diff.as_tree(html, other_html)

You can pass input html as str or bytes (it will be parsed with lxml.html.fromstring in this case), or as an already parsed lxml.html.HtmlElement.

Project details


Release history Release notifications

Download files

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

Files for extract-html-diff, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size extract-html-diff-0.1.0.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page