Skip to content

Instantly share code, notes, and snippets.

@loisaidasam
Last active August 29, 2015 14:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save loisaidasam/2625769862c81f943f58 to your computer and use it in GitHub Desktop.

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