Skip to main content

ParseChain

A way to parse html fluently and as declarative as possible. This is in alpha stage now, things will change.

Installation

pip install parsechain

Usage

import requests
from parsechain import C, Response

# Fetch html and cast it
response = Response.cast(requests.get(...))

# Get a movie title and rating
title = response.css('h1 .title').text
rating = response.css('.left-box').inner_text.re(r'IMDb: ([\d.]+)').float

# Or both
movie = response.root.multi({
    'title': C.css('h1 .title').text,
    'rating': C.css('.left-box').inner_text.re(r'IMDb: ([\d.]+)').float,
})

The last example could be extended to show chains reuse:

def by_label(label):
    return C.css('.left-box').inner_text.re(fr'{label}: ([\w.]+)')

parse_movie = C.multi({
    'title': C.css('h1 .title').text,
    'rating': by_label('IMDb').float,
    'status': by_label('Status').trim,
})

movie = parse_movie(response.root)  # Pass a root of a tree

The complete list of available ops could be seen in parsechain.chains.Ops class. Proper documentation to follow, some day ;)

Metadata

Release files for parsechain 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for parsechain 0.0.3
File Size Uploaded Provenance Actions
parsechain-0.0.3.tar.gz 8.0 kB Without provenance Details for parsechain-0.0.3.tar.gz

Release files / parsechain-0.0.3.tar.gz

Download URL parsechain-0.0.3.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
54c0210d7be46b1cce64973b64784cbb63287efce755b8ee9095f93ff07f1274
BLAKE2b-256 checksum
How to use checksums
694f09ccf5e5bfa64a55b83fd99babb4bb1a4cce90a3cc321b13aa337fd1fa46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Security for parsechain 0.0.3

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.

Release history Release notifications | RSS feed

This release

0.0.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page