Skip to main content

Slice and dice html on the command line using CSS selectors.

Example

Let’s say you want to grab all the links on http://example.com/foo/bar:

$ curl http://example.com/foo/bar | que "a->href"

Let’s say that gave you 3 lines that looked like this:

/some/url?val=1
/some/url2?val=2
/some/url3?val=3

Ugh, that’s not very helpful, so let’s modify our selection:

$ curl http://example.com/foo/bar | que "a->http://example.com{href}"

Now, that will print:

http://example.com/some/url?val=1
http://example.com/some/url2?val=2
http://example.com/some/url3?val=3

Selecting

Not sure how to use CSS Selectors?

The selector is divided into two parts separated by ->, the first part is the traditional selector talked about in the above links and the second part is the attributes you want to print to the screen for each match:

$ css.selector->attribute,selector

The Selector part uses Python’s string formatting syntax so you can embed the attributes you want within a larger string.

Notes

  • If you need a way more fully featured html command line parser, try hq.

Metadata

Release files for que 0.0.1

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

Source distribution (sdist)

Source distribution for que 0.0.1
File Size Uploaded Provenance Actions
que-0.0.1.tar.gz 3.1 kB Without provenance Details for que-0.0.1.tar.gz

Release files / que-0.0.1.tar.gz

Download URL que-0.0.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
418f3f0d61a41db2e852de5133cbc759e8bddc3d8e405efdea4267f697eade55
BLAKE2b-256 checksum
How to use checksums
77d117844565881e171503324c3a03e1194874f784c1d36ecf0b815860cd3175
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for que 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.

Release history Release notifications | RSS feed

This release

0.0.1 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