Skip to content

Instantly share code, notes, and snippets.

@idlecool
Created January 16, 2016 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idlecool/26cce5a2a299b2f51409 to your computer and use it in GitHub Desktop.
Save idlecool/26cce5a2a299b2f51409 to your computer and use it in GitHub Desktop.
cron job to alert when a car is posted on craigslist
#!/bin/bash
countfile="/root/old.count.txt"
touch $countfile
old_count=$(cat $countfile)
new_count=$(curl -s https://sfbay.craigslist.org/search/cto\?search_distance_type\=mi\&min_price\=2000\&max_price\=8000\&auto_make_model\=honda\&max_auto_miles\=100000\&auto_title_status\=1\&query\=%22mountain+view%22+%7C+%22palo+alto%22+%7C+%22sunnyvale%22+%7C+%22menlo+park%22+%7C+%22redwood+city%22+%7C+%22santa+clara%22 | grep paginator| tail -n 1 | ruby -e 'puts /totalcount">([0-9]*)/.match($stdin.read())[1]')
if [ $old_count -ne $new_count ]; then
curl -X POST https://maker.ifttt.com/trigger/cars/with/key/XXXXXXXXXXXXXXXX
echo $new_count > $countfile
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment