Skip to main content

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

Project details


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.15.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

purifier-0.2.15-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file purifier-0.2.15.tar.gz.

File metadata

  • Download URL: purifier-0.2.15.tar.gz
  • Upload date:
  • Size: 16.3 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

Hashes for purifier-0.2.15.tar.gz
Algorithm Hash digest
SHA256 c395ab11fe54d3841f36e3a169ae9032c686fb4b95435dd8b0ef8e12ea3fe3d5
MD5 a9f02359927fa754713348c4ffbdf177
BLAKE2b-256 e321f874bb490d75b5e93a40017f5ab8bfc7190bc03d8d8f10ab9fc25eecb38f

See more details on using hashes here.

File details

Details for the file purifier-0.2.15-py3-none-any.whl.

File metadata

  • Download URL: purifier-0.2.15-py3-none-any.whl
  • Upload date:
  • Size: 16.2 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

Hashes for purifier-0.2.15-py3-none-any.whl
Algorithm Hash digest
SHA256 700fd4257e944fc99406e241cef9b9c4dc6a5885df885c29093a6c49a6a2c819
MD5 5d5be109c02ae7aa7aa622d7162bb472
BLAKE2b-256 c8de0e29ce799a5e68f039455578a7820e31bfa75e1b95af369ef1d54cc430b2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page