Tuesday, October 05, 2010

Tipidpc feed script

Out of boredom, I was able to create a simple script to get feeds from tipidpc. I was getting frustrated
while waiting, refreshing and reading at items. Finally, I made a script to automatically display the new active items for sale every 30 seconds. If you guys have linux/unix, install a text browser 'links' to run this.


<code>
#!/bin/sh
while [ 1 ]
do
MSG=`links -source http://www.tipidpc.com/ | sed -n '/Buys/,$ !p' | egrep "PHP|viewitem" | sed 's/[^>]*>//' | sed 's/<.*//' | tr -d "\n" | sed 's/Posts/\n/g'`
echo "$MSG"
X=`echo "$MSG" | grep -i "laptop"`
if [ -n "$X" ]
then
echo "emailing....."
echo $X | mail -s "subject" user@email.com
fi
sleep 30
clear
done

</code>

There you go.. A simple script that also emails me on items that i'm interested on. Viewing this on my terminal is really addicting. Since there are lots of new items being posted every 30 secs.
Additional feature might be added to display the hyperlink in the terminal so that I can easily ctrl+click to browse it immediately.

Enjoy!


No comments: