MDR
MDR is a library detect and extract listing data from HTML page. It implemented base on the Finding and Extracting Data Records from Web Pages but change the similarity to tree alignment proposed by Web Data Extraction Based on Partial Tree Alignment and Automatic Wrapper Adaptation by Tree Edit Distance Matching.
Requires
numpy and scipy must be installed to build this package.
Usage
Detect listing data
MDR assume the data record close to the elements has most text nodes:
[1]: import requests
[2]: from mdr.mdr import MDR
[3]: mdr = MDR()
[4]: r = requests.get('http://www.yelp.co.uk/biz/the-ledbury-london')
[5]: candidates, doc = mdr.list_candidates(r.text.encode('utf8'))
...
[8]: [doc.getpath(c) for c in candidates[:10]]
['/html/body/div[2]/div[3]/div[2]/div/div[1]/div[1]/div[2]/div[1]/div[2]/ul',
'/html/body/div[2]/div[3]/div[2]/div/div[1]/div[2]',
'/html/body/div[2]/div[3]/div[2]/div/div[1]/div[2]/div[2]',
'/html/body/div[2]/div[3]/div[1]/div/div[4]/div[1]/div/div[1]/div/div[2]/div[1]/div[1]/div',
'/html/body/div[2]/div[3]/div[1]/div/div[4]/div[2]/div/div[3]',
'/html/body/div[2]/div[3]/div[1]/div/div[4]/div[1]/div/div[2]/ul/li[2]/div/div/ul',
'/html/body/div[2]/div[3]/div[2]/div/div[1]/div[1]/div[2]/div[1]',
'/html/body/div[2]/div[3]/div[2]/div/div[1]/div[2]/div[2]/div[1]/table/tbody',
'/html/body/div[2]',
'/html/body/div[2]/div[4]/div/div[1]']
Extract data record
MDR can find the repetiton pattern by using tree matching under certain candidate DOM tree.then it will build a mapping from so-called seed element to a list of matched elements from different DOM trees.
Used with annotation (optional)
You can annotate the seed record with any tools (e.g. scrapely) you like, then mdr will be able to find the other data in the page.
e.g. you can find this demo page here. the colored data in first row are annotated manually, the rest are extracted by MDR.
License
MIT
Metadata
Release files for mdr 0.0.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 | Provenance | Actions |
|---|---|---|---|---|
| mdr-0.0.1.tar.gz | 49.3 kB | Without provenance | Details for mdr-0.0.1.tar.gz |
Release files / mdr-0.0.1.tar.gz
| Download URL | mdr-0.0.1.tar.gz |
|---|---|
| Size | 49.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d7be84742642e82e96ab555de31904a90e109a3ff92f2586b6c16920589bbb3
|
|
BLAKE2b-256 checksum How to use checksums |
9a9ec8330017d8c0aec9a053f29310137da11d5d33633f5d806404c38d3b13e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for mdr 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.