Google Trends Script

2013.09.23   11:37AM   programming

Recently I tried out GeekTool (a Mac version of Linux's Conky) and I am quite impressed! Right now I have scripts on my desktop that show the time, weather, unread emails, network stats and laptop stats. And I just threw together a script of my own:


rm ./spicy.txt


echo "      -- SPICY GOOGLE SEARCHES --"
curl --silent "$url" | grep "Spicy" | sed -n -e 's/.*">\(.*\)<\/a>.*/\1/p' >> ./spicy.txt
while read p; do
    echo $p
    sleep $[ ( $RANDOM % 14 ) + 1 ]s
    echo "    (" | tr -d "\n"
    curl -s --get --data-urlencode "q=wikipedia $p" | \
        egrep -o 'is a.........................|was a........................' | \
        head -n1 | tr -d '\n' && echo "...)"
done < ./spicy.txt		

This script pulls the hour's hottest google search terms, and then gets a short description from wikipedia. You should note that running this script very often will result in curl not working (Google's servers will start blocking your address). The random sleep helps to prevent this. You can download the script here. Feel free to use this script for your own Bash adventures. Happy coding!

by Chris McComb







RSS Feed

© Chris McComb 2013