HTML Matcher
The pypi package in Python contains a series of functions for calculating the similarity ratio between pages in websites or web applications.
How to INSTALL?
pip install html-matcher
How to USE?
By comparing the HTML structure, style, or both, the similarity ratio can be computed. Two techniques are available for structure comparison: Matching Subsequences (MS) and All Path Tree Edit Distance (APTED). One algorithm that uses the jaccard similarity metric is offered for style comparison.
Structure
MS
Example
ms = MatchingSubsequences()
ratio = ms.similarity(page1,page2)
or you can use our improved method of MS that provides better results
ms = MatchingSubsequencesOptimized()
ratio = ms.similarity(page1,page2)
APTED
Example
apted = AllPathTreeEditDistance()
ratio = apted.similarity(page1,page2)
or you can use our improved method of APTED that reduces computational time
apted = AllPathTreeEditDistanceOptimized()
ratio = apted.similarity(page1,page2)
Style
Each html document's css classes are extracted, and the jaccard similarity of the sets of classes is calculated.
Jaccard Similarity
J(A,B) = |A ∩ B| / |A U B|
Example
style = StyleSimilarity()
ratio = style.similarity(page1,page2)
Structure & Style
We must pass a weight for each metric when combining similarity measures (k). The default value is 0.5, but in our experiments, we found that, when comparing web pages based on their similarity ratio, structure takes precedence over style, so 0.7 produces better results.
k * similarity(page_1, page_2) + (1 - k) * similarity(page_1, page_2)
Example
style = StyleSimilarity()
apted = AllPathTreeEditDistanceOptimized()
method = MixedSimilarity(apted, style, k=0.7)
ratio = method.similarity(page1,page2)
Release files for html-matcher 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 | |
|---|---|---|---|
| html-matcher-0.1.1.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| html_matcher-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.5 kB
Release files / html-matcher-0.1.1.tar.gz
| Download URL | html-matcher-0.1.1.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
045ed9150d43921949ba403822aa0e7d2a5d9868b46dae2600324c9afe9271f8
|
|
BLAKE2b-256 checksum How to use checksums |
6e566060159da62cb3942a53c0ecc76203c9c6919399e3eea81319e36d173332
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.11
|
Release files / html_matcher-0.1.1-py3-none-any.whl
| Download URL | html_matcher-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f71c1dc157b71fdf906f67fdc1e04d5e801ac3be6128e7ed1b987b0f7bde56fb
|
|
BLAKE2b-256 checksum How to use checksums |
de0d13544d03218d42a84aff9686fb4aeb3367b3d64d904900ef65019320c493
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.11
|