Skip to main content

CSS selectors for parsing html on the command line

Project description

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

Quick start

Let’s say you want to grab all the links on

$ curl | que "a->href"

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


Ugh, that’s not very helpful, so let’s modify our argument a bit:

$ curl | que "a->{href}"

Now, that will print:


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.


Find all the “Download” links on a page:

que has support for the the non-standard :contains css selector

$ curl | que "a:contains(Download)->href"

Select all the links with attribute data that starts with “foo”:

$ curl | que "a[data|=foo]->href"


You can use pip to install stable:

$ pip install que

or the latest and greatest (which might be different than what’s on pypi:

$ pip install git+


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

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

que-0.0.2.tar.gz (3.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page