Create a gist now

Instantly share code, notes, and snippets.

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!

Dependencies:

Optionally: add ESPN headlines to your motd by:

Adding the following to your crontab:

0 * * * * $HOME/bin/espn-headlines.sh > $HOME/.ESPN

Adding the following to your ~/.bashrc:

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

Based on Eric Chiang's answer to my question:

http://stackoverflow.com/questions/26635752/pup-help-limiting-results

#!/bin/bash
# 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 http://espn.go.com/ | $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