A simple scraping library.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
purifier-0.2.12.tar.gz
(16.1 kB
view details)
Built Distribution
purifier-0.2.12-py3-none-any.whl
(15.9 kB
view details)
File details
Details for the file purifier-0.2.12.tar.gz
.
File metadata
- Download URL: purifier-0.2.12.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.9.7 Linux/5.13.0-44-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b19796d7976ff1b254009303428b7c9290736fe1dd84dca7cae4f07507719174 |
|
MD5 | 90bdb2cd9d37d10218ea58024bc4a0c8 |
|
BLAKE2b-256 | 16dfd834fcdfb643b47ea4058794dc1621ed5e38eed5cce488db91b66a209f30 |
File details
Details for the file purifier-0.2.12-py3-none-any.whl
.
File metadata
- Download URL: purifier-0.2.12-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.9.7 Linux/5.13.0-44-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20144211a1eecac9bd85969fc48b38e64840480f25892d343ef7ac80cc366343 |
|
MD5 | 5721ae8bf64bd2fc9591955ed4aaf3b2 |
|
BLAKE2b-256 | dbf1022b14046c9e65f8cfa27b60fb57725ee25a61a3cbe2389418df993a31c6 |