Today I Learned - Rocky Kev

TIL jq and htmlq

POSTED ON:

TAGS:

Today I learned about jq and htmlq, which are two command line libraries that make curl requests then return filtered data!

jq

Repo: https://stedolan.github.io/jq/

How it looks:

// command line
jq '.[0] | {message: .commit.message, name: .commit.committer.name}'


// Result
{
  "message": "Merge pull request #162 from stedolan/utf8-fixes\n\nUtf8 fixes. Closes #161",
  "name": "Stephen Dolan"
}

htmlq

Repo: https://github.com/mgdm/htmlq

Like jq, but for HTML. Uses CSS selectors to extract bits of content from HTML files.

How it looks

// command
curl --silent https://www.rust-lang.org/ | htmlq '#get-help'


// Result
<div class="four columns mt3 mt0-l" id="get-help">
        <h4>Get help!</h4>
        <ul>
          <li><a href="https://doc.rust-lang.org">Documentation</a></li>
          <li><a href="https://users.rust-lang.org">Ask a Question on the Users Forum</a></li>
          <li><a href="http://ping.rust-lang.org">Check Website Status</a></li>
        </ul>
        <div class="languages">
            <label class="hidden" for="language-footer">Language</label>
            <select id="language-footer">
                <option title="English (US)" value="en-US">English (en-US)</option>
<option title="French" value="fr">Français (fr)</option>
<option title="German" value="de">Deutsch (de)</option>

            </select>
        </div>
      </div>

Related TILs

Tagged:

TIL jq and htmlq

jq and htmlq, which are two command line libraries that make curl requests then return filtered data. jq is for json, and htmlq is for html!

TIL about going up and down in your bash history

Your bash history is saved with up/down arrow keys. Which means you shouldn't save your passwords on it.

TIL How to determine what security group you're in

These commands will help you figure out what group you're in, and if you belong to the group that can modify files.