I was looking for a way to have an automated search for some items I’m looking for on Craigslist, but nothing exists in Craigslist to email you daily/weekly for items matching a particular string. I found a few websites that offered this functionality via an application, but I’m not down for that. Instead I wrote this simple korn shell script. Enjoy!
#!/bin/sh
echo "--> Setup...";
directory=/my/dir/for/results/;
filename="craigslist_dell_monitor.html";
path="${directory}${filename}";
website="http://mycity.craigslist.org/search/sss?query=dell+2005fpw&minAsk=min&maxAsk=max"
echo "--> Searching for Dell Monitor...";
wget -O ${path} ${website}
ls -la ${directory}
echo "--> Checking for results...";
cat ${path} | grep "Found:"
if [ $? == 0 ]
then
echo "--> Sending results email...";
echo ${website} | mail -s "craigslist search - Dell Monitor" myemail@gmail.com
else
echo "--> No results.";
fi
exit;
Any guesses on what I was searching for?
