hqcl

1.2.0 • Public • Published

hq

hq is like jq for HTML

Install

npm i hqcl

Usage

hq "<query> | <slice or member or method>..." [<url or file>]
  • query to get elements.
    • Syntax is the same as syntax you use in document.querySelectorAll or jquery: #elementId .elementClassName elemen-tag.
    • Returns list of matched elements.
    • Examples: div.title, #footer .link, .result.active
  • slice: Get portion of results.
    • Syntax: .[<start>:<end>]
    • Returs sliced list of results
    • Examples: .[:6], .[2:10], .[5:]
  • member: Get a member of results
    • Syntax: .<member name>
    • Examples: .textContent, .length
  • method: Invoke a method of results
    • Syntax: <method name>, <method name(...args[])>
    • Examples: getAttribute(href), toUpperCase

Keep "piping" in hq argument until you get the final result you want or use other unix's string processing utilites.

Feed HTML

From stdin:

html=$(curl https://duckduckgo.com/html?q=feet)
echo $html | hq ".result__a | .textContent"

From file/url:

hq ".result__a | .textContent" ~/toes.html
hq ".result__a | .textContent" "https://duckduckgo.com/html?q=ankle"

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.2.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.2.0
    1
  • 1.1.0
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i hqcl

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

5.17 kB

Total Files

4

Last publish

Collaborators

  • khanhas