Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:08
What would you like to do?

A command line script for grabbing ESPN's latest headlines!

Throw this baby into your $HOME/bin directory (assuming it exists and is in your $PATH) and chmod it to 755 and you'll be cruising!


Optionally: add ESPN headlines to your motd by:

Adding the following to your crontab:

0 * * * * $HOME/bin/ > $HOME/.ESPN

Adding the following to your ~/.bashrc:

if [ -f $HOME/.ESPN ]; then
    echo "The latest ESPN headlines:"
    cat $HOME/.ESPN
    echo ""

Based on Eric Chiang's answer to my question:

# Requirements:
# jq
# pup >= 0.3.2
# jq explanations:
# get the child key of each element in the list
# .[].children
# get the text key of the first element in the list
# [0].text
curl -s -S | $HOME/bin/pup .headlines li json{} | $HOME/bin/jq --raw-output '.[].children [0].text'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment