Recently I've been searching for a new apartment to move into once I graduate from college, and got tired of querying Craigslist (the best site I've found for this purpose) with the same terms over and over again. So, I thought it would be useful to write a simple script to automatically send me a list of properties that match my search criteria once per week.
My complete program can be found here.
If anyone would like to create their own query, feel free to fork my program on Github for your own use.
I used this source for the Craigslist portion, and this source for the email portion.
Here's what an email looks like:
My complete program can be found here.
If anyone would like to create their own query, feel free to fork my program on Github for your own use.
I used this source for the Craigslist portion, and this source for the email portion.
Here's what an email looks like:
As you may have guessed, my query is for a room for rent in San Francisco, along with a few other filters. Note that my script only returns the first 5 results.
The biggest issue I encountered while writing this program was getting an email to send to my primary Yahoo address. I eventually gave up and tried using my secondary Gmail account. However, in order for the program to send via the Gmail account, I had to enable access to all "less secure applications", and couldn't figure out how to allow just my application. So, I instead created an entire new Google account including Gmail, and used that to send emails to my primary Yahoo account. This solution works quite nicely, although I had to jump through several hoops.
A smaller issue I had was that sometimes the length of the results I was trying to email was too long, which led me to reduce the number of results to the top 5. This was a strange issue, since sometimes 7 results was too long for it to handle, but at other times it had no problem sending 25 results. Post in the Github project page if anyone has a good explanation for this.
After the script was working, I decided I wanted it to run on a schedule. To accomplish this, I used Automator (which comes pre-installed on Mac OS X), but there are many tools that are available. I set it to run the script every Monday at 5 pm.
This was a small but fun and useful project to gain some experience using Python, script scheduling, and open source APIs.

Comments
Post a Comment