Expanding on the previous code Traffic Alerts
Here is a slight variation on the previous script using twitter feeds
This one scans twitter for local traffic alerts
Code:
Today=$(date '+%Y-%m-%d')
sinceDate=$Today
untilDate=$Today
TwitterUser=NYS_Traffic
numPosts=20
Terms="+holland+OR+turnpike+OR+lincoln"
curl --silent http://search.twitter.com/search.atom?q=$Terms+from%3A$TwitterUser+since%3A$sinceDate+until%3A$untilDate | awk '/<title>/' | sed '1d' | sed | sed 's/<content type="html">//'| sed 's/<\/content>//' | sed 's@<\([^<>][^<>]*\)>\([^<>]*\)</\1>@\2@g' | sed 's/<\;.*a>\;//g' | sed 's/&//g' | sed 's/apos;//g' | sed "$numPosts"q | sed 's|... Read more at||' | sed 's|http://.*||' | sed 's/Bridge Tunnel Alert//' | sed 's/^[[:space:]]*\(.*\)[[:space:]]*$/\1/'
so much of the explination remains the same from the prior post with the addition of the variable
$Terms
again I'm using TODAY as the date range limit (i don't care about yesterdays traffic and tomorrow isn't here yet...)
$TwitterUser is set to my areas traffic feed YMMV (pun intended)
$numPosts is how many to display at a time
with the addition of one new variable - this sets key words you want to have in the posts before adding them to the output. In my case I live around New York City / New Jersey area most often I am concerned with the tunnels, bridges and the NJ turnpike. so my search terms are : holland, turnpike, lincoln
the format for the variable is +holland+OR+turnpike+OR+lincoln
it MUST BE THAT WAY with the leading + and the +OR+ in between each item and NO ENDING + YES I KNOW i could have set them up in and array or something more friendly... I left it down and dirty for simplicity sake.
So in order for a post to be show in the output IT MUST CONTAIN at least ONE of those terms other than that I prob don't care.
I am fairly certain (HAVE NOT TESTED) you can swap +AND+ instead of +OR+ and this would require ALL the search terms to exist in the post. feel free to test that one out.
So now you begin to see the flexibility of this simple little script -

cheers!
here's a screen shot