Cooper Leong

Github LogoLogoLogo

houseBot - Renting my dream student house

Bash, Selenium, Twilio, JavaScript/NodeJS, Cron Job

This was one of the most important projects that I've worked on.

The student housing scene at my university is excessively competetive, and getting a good student house has become an increasingly difficult task over the last 3 years. So we decided to do something that would give us an edge on other students. There was one house in particular that we knew was going on the market at some point in the coming month, we didn't know what day, or what time, all we knew was that we wanted it. These houses are notorious for getting leased within less than a day, so we had lots of competition. The way that the leasing system worked was that the first person to respond to the ad saying they're interested, gets the place, a first come first serve system.

Once the house was uploaded to the website, it was a free for all.

Luckily I had written a script in JavaScript that used Selenium to scrape the website for the listing, and if it was there, to send a text using Twilio to myself and my housemates saying that the house was on the market. The script was triggered off a cron job that ran every 30 minutes, it was even hosted on my "always on" pc at home, so there would be no down time. You can view the script here.

Then that fateful day came, would my script hold up when we needed it the most...the answer is yes...but also no.

We noticed that there were a bunch of new listings on the website, in which the house we wanted should've been among them, but it wasn't there. So we called the landlord's office and inquired about the unit, and they told us that it was already leased. How could this be? We literally created a script so that we could lease that house! How did someone beat us to it?

What we didn't realize would happen is that people waited outside the landlord's office until the unit was posted, and handed them a signed lease within seconds of the posting. First come first serve.

The script worked perfect, but since it ran exactly on the half hour, it was enough time for them to post the unit, sign the lease, and take the listing off of the website.

When we called, although devastated, we inquired about any other units available, and they said there was one more that wasn't signed. So we lined up outside the landlord's office, first thing in the morning, handed them a lease and signed a different house. Little did we know that this other unit was better, bigger, cheaper, and in a better location than the one we thought we wanted. So at least all that hard work paid off!

Mistakes and Lessons Learned

The most glaring flaw was running the cron job on the half hour rather than every minute. Running it every minute led to a memory error bug in Chromium that I couldn't fix in time, so unfortunately we missed our window. Working on this project was not at all a task, it felt great knowing that I was finding a smart loophole that would give us an edge. We would spend hours a day just going through the listings to see if it had been posted, and we realized that that was such a waste of our time, we're software developers, let's just automate this!

I love working on projects of this sort, where the goal is of actual value to me, and saves me time on something that is redundant in my daily life.