Need to find an apartment? Turnover times got ya down? Throw this bash script on a cron job and never miss a posting again!
Requires: *nix, mailx, cron, an apartment agency that lists their vacancies online.
Click "Read more" for the code listing
Note the wget line: you will have to change the URL to your appropriate real estate agency's listings page.
Note the egrep line: if buildingshome.asp contains a line of text with the word "Central" or "Corydon" in it, write that line and the 3 lines -Before it to the file newspots.txt. I use this to find apartments in a specific part of town, ie Central or Corydon. You will have to change this suitably.
Note the mailx line: the -subject is "SussexSpots", and the email has newspots.txt -attached.
This script is, of course, very simple - but, you can extend it easily. I had it set up in a cron job to run every hour, and had it emailing my gmail account - which meant I got a notification on my android phone every time new listings were posted for the areas I was interested in.
Hope this helps somebody!
Requires: *nix, mailx, cron, an apartment agency that lists their vacancies online.
Click "Read more" for the code listing
#!/usr/bash
rm buildingshome.asp
rm oldspots.txt
mv newspots.txt oldspots.txt
wget http://www.sussexrealty.ca/buildingshome.asp
egrep 'Central|Corydon' buildingshome.asp -B 3 > newspots.txt
if diff ./oldspots.txt ./newspots.txt > /dev/null; then
echo damn.
else
echo "here ya go!" | mailx -s SussexSpots -a ./newspots.txt youremail@isp.tld
fi
Note the wget line: you will have to change the URL to your appropriate real estate agency's listings page.
Note the egrep line: if buildingshome.asp contains a line of text with the word "Central" or "Corydon" in it, write that line and the 3 lines -Before it to the file newspots.txt. I use this to find apartments in a specific part of town, ie Central or Corydon. You will have to change this suitably.
Note the mailx line: the -subject is "SussexSpots", and the email has newspots.txt -attached.
This script is, of course, very simple - but, you can extend it easily. I had it set up in a cron job to run every hour, and had it emailing my gmail account - which meant I got a notification on my android phone every time new listings were posted for the areas I was interested in.
Hope this helps somebody!
No comments:
Post a Comment