Purifier
A simple scraping library.
It allows you to easily create simple and concise scrapers, even when the input is quite messy.
Example usage
Extract titles and URLs of articles from Hacker News:
from purifier import request, html, xpath, maps, fields, one
scraper = (
request()
| html()
| xpath('//a[@class="titlelink"]')
| maps(
fields(
title=xpath("text()") | one(),
url=xpath("@href") | one(),
)
)
)
result = scraper.scrape("https://news.ycombinator.com")
result == [
{
"title": "Why Is the Web So Monotonous? Google",
"url": "https://reasonablypolymorphic.com/blog/monotonous-web/index.html",
},
{
"title": "Old jokes",
"url": "https://dynomight.net/old-jokes/",
},
...
]
Installation
pip install purifier
Docs
- Tutorial
- Available scrapers — API reference.
Metadata
Release files for purifier 0.2.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| purifier-0.2.16.tar.gz | 16.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| purifier-0.2.16-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.5 kB
Release files / purifier-0.2.16.tar.gz
| Download URL | purifier-0.2.16.tar.gz |
|---|---|
| Size | 16.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8a25a027f5b33188a9af6d5d9c1fcd1ef9587092ed471ca6de668db9251239a
|
|
BLAKE2b-256 checksum How to use checksums |
74964560a645e8c91d47791cf88c71ff2f0243c4a4e1f71b2d5f699cb643c3c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.9.7 Linux/5.13.0-44-generic
|
Release files / purifier-0.2.16-py3-none-any.whl
| Download URL | purifier-0.2.16-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19ba1e1aab895ef964cd4f7905607edb5d2b6e28564161fc8ee7473bdfc28bee
|
|
BLAKE2b-256 checksum How to use checksums |
fcabfbed5979fe23d64873d2732b8df3b089ec5f4ba604fba88c0bb6eaf4b91b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.9.7 Linux/5.13.0-44-generic
|