All Projects → plainas → Tq

plainas / Tq

Licence: mit
Perform a lookup by CSS selector on an HTML input

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Tq

Json 2 Kotlin
Convert JSON to Kotlin Data Classes
Stars: ✭ 148 (-23.32%)
Mutual labels:  command-line-tool, command-line, json
Fblog
Small command-line JSON Log viewer
Stars: ✭ 137 (-29.02%)
Mutual labels:  command-line-tool, command-line, json
Jl
Functional sed for JSON
Stars: ✭ 449 (+132.64%)
Mutual labels:  command-line-tool, command-line, json
Commandtrayhost
A command line program monitor systray for Windows
Stars: ✭ 303 (+56.99%)
Mutual labels:  command-line-tool, command-line, json
Xidel
Command line tool to download and extract data from HTML/XML pages or JSON-APIs, using CSS, XPath 3.0, XQuery 3.0, JSONiq or pattern matching. It can also create new or transformed XML/HTML/JSON documents.
Stars: ✭ 335 (+73.58%)
Mutual labels:  command-line, json, css-selector
Jsonui
jsonui is an interactive JSON explorer on your command line
Stars: ✭ 583 (+202.07%)
Mutual labels:  command-line-tool, command-line, json
Cascadia
Go cascadia package command line CSS selector
Stars: ✭ 67 (-65.28%)
Mutual labels:  command-line-tool, command-line, css-selector
Jsonwatch
Track changes in JSON data from the command line
Stars: ✭ 130 (-32.64%)
Mutual labels:  command-line-tool, json
Git Tidy
Tidy up stale git branches.
Stars: ✭ 137 (-29.02%)
Mutual labels:  command-line-tool, command-line
Brotab
Control your browser's tabs from the command line
Stars: ✭ 137 (-29.02%)
Mutual labels:  command-line-tool, command-line
Gossed
Push the standard output of ANY program to browsers as Server Sent Events
Stars: ✭ 138 (-28.5%)
Mutual labels:  command-line-tool, command-line
Pueue
🌠 Manage your shell commands.
Stars: ✭ 2,471 (+1180.31%)
Mutual labels:  command-line-tool, command-line
Artisan Menu
📝 Artisan Menu - Use Artisan via an elegant console GUI
Stars: ✭ 141 (-26.94%)
Mutual labels:  command-line-tool, command-line
Asciigraph
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.
Stars: ✭ 1,805 (+835.23%)
Mutual labels:  command-line, command-line-tool
Check It Out
A command line interface for Git Checkout. See branches available for checkout.
Stars: ✭ 127 (-34.2%)
Mutual labels:  command-line-tool, command-line
Rq
Record Query - A tool for doing record analysis and transformation
Stars: ✭ 1,808 (+836.79%)
Mutual labels:  command-line-tool, json
Desktoppr
Simple command line tool to set the desktop picture on macOS
Stars: ✭ 127 (-34.2%)
Mutual labels:  command-line-tool, command-line
Typin
Declarative framework for interactive CLI applications
Stars: ✭ 126 (-34.72%)
Mutual labels:  command-line-tool, command-line
Xioc
Extract indicators of compromise from text, including "escaped" ones.
Stars: ✭ 148 (-23.32%)
Mutual labels:  command-line-tool, command-line
Dejavu
Quickly detect already witnessed data.
Stars: ✭ 151 (-21.76%)
Mutual labels:  command-line-tool, command-line

Travis build status

tq

tq is command line utility that performs an HTML element selection on HTML content passed to the stdin. Using css selectors that everybody knows.

Since input comes from stdin and output is sent to stdout, it can easily be used inside traditional UNIX pipelines to extract content from webpages and html files.

tq provides extra formating options such as json-encoding or newlines squashing, so it can play nicely with everyones favourite command line tooling.

Installation

sudo pip3 install https://github.com/plainas/tq/zipball/stable

Example usage

Get headlines from hacker news

curl https://news.ycombinator.com/news | tq -tj ".title a"

Get the title of an html document stored in a file

cat mydocument.html | tq -t title

Get all the images from a webpage

curl -s 'http://example.com/' | tq  "img" -a src | wget -i -

Notice that tq doesn't provide a way to make http requests or read files. You can use your favorite HTTP client, or provide the html source from any source you want.

For a modern, user friendly http client, check httpie. Or you can just use curl, wget, netcat, etc.

Command options

  • SELECTOR A css selector

  • -a ATTRIBUTE --attr=ATTRIBUTE Outputs only the contents of the html ATTRIBUTE.

  • -t, --text Outputs only the inner text of the selected elements.

  • -p, --parent Select the parent elements instead.

  • -q, --squash Squash lines.

  • -s, --squash-space Squash spaces.

  • -j, --json-lines JSON encode each match.

  • -J, --json Output as json array of strings.

  • -v, --version Prints tq version

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].