Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

grep for HTML; CLI for pyquery

Project Description


grep for HTML; CLI for pyquery

## Demo

$curl -s | pquery '.content a' -p text

`pquery` is intended to integrate into your UNIX pipeline.

## Install

`pip install pquery`

## Syntax

pquery <selector>
pquery <selector> -p <projector>
pquery <selector> -f <format_string>
pquery -h | --help

-p: project the dict onto field `<projector>`.
-f: equivalent of `<format_string>.format(item)`,
where item is the dict form of one selected HTML element.
-h | -v: shows this doc.

Dict keys:
'tag': The HTML tag
'html': Inner HTML of the element
'text': Inner text of the element
...: [optional] Other attributes: e.g. 'href'

## Why

`grep` is powerful for **lines**.
HTML is structured and not line processor friendly.
CSS selector is a natural grep for HTML.
This script simply wraps [pyquery]( to provide a CLI.

## Example 1

A [course webpage](
lists slides in `pdf` and `pptx`.
Want to download all the PDFs.
This saves you some click.

wget --load-cookies=cookies.txt -O- '' | pquery a -p href | grep pdf | xargs -P 5 -I{} wget {}

It's tedious to directly grep the PDF links out from HTML.

Release History

This version
History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(3.1 kB) Copy SHA256 Hash SHA256
Source None Sep 26, 2015

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate