I wrote a script to get a Banksy

How I created an app with Heroku and Twilio to check a website every minute and call me if the site changed, notifying me of available Banksy artwork.

Leah Culver
Oct 24 · 5 min read

I was vacationing in Florence when I noticed that my boyfriend, street-artist fnnch, was compulsively refreshing a webpage on his phone. It turns out that he was closely watching Gross Domestic Product, a storefront from the artist Banksy.

Banksy was about to release new artwork due to a copyright dispute, and he hadn’t released editioned artwork to the public for over a decade. This was potentially a historic opportunity.

The website read “Coming soon”, so fnnch and I assumed it would open suddenly with everything for sale — what’s known as a “drop”.

Website for Gross Domestic Product

As a Banksy fan myself, the compulsive refreshing made a lot of sense. As a programmer, however, I thought it unnecessary to spoil a nice vacation when we could have a machine do the work for us.

I did a quick search on the web (and the App Store) to see if I could find something that would periodically check the website and send us a message if it changed. I was disappointed to find that most apps would only check every hour. Definitely not fast enough!

Luckily I know some Python, how to set up a quick app on Heroku, and how to use Twilio to send text messages. I told fnnch, “I got this.”

Making the app

Thanks to jet lag, I woke up at 3 am. When better to start hacking?

I set up a phone number on Twilio that could programmatically text me. Then I downloaded the how-to Django app from Heroku and began customizing it.

I wanted the app to download a copy of the HTML source code from the website and compare it to a previously downloaded version. I used the Python Requests library to fetch the contents of the site and save it to a file called grossdomesticproduct.html. I then used that file to compare new requests.

I’d like to mention that the grossdomesticproduct.com source code was very tidy, so hats off to Banksy’s web developer! 🎩

Now that I had a way to compare the site, I needed it to send me (and fnnch) a text message. Luckily, with Twilio’s Python SDK, that was super easy!

At this point I wanted to quickly test my code, so I set up a website — banksy-pickup.herokuapp.com — that would run my code when I visited.

It worked!

A very simple website. No updates yet!

Next I needed to get this bit of code checking the website every minute.

Heroku has an add-on called Heroku Scheduler that can be configured to run a script on a regular basis. Unfortunately the fastest it can run is once every 15 minutes. Bummer.

For speed, I needed to use a Python process called APScheduler. I updated the example clock.py script from the Heroku APScheduler documentation to fit my needs.

I started this process using heroku ps:scale clock=1 and now everything worked!

I configured the app to send me a text message every morning at 8 am, just to let me know it was still running.

Morning updates from the app.

I proudly showed my progress to fnnch. He was excited about the app but worried about timezones. Banksy lives in the UK, so what if he updated the site while we were asleep?!

To make sure we got notified in a timely manner, fnnch had the idea to have the app call us. We put a “Banksy Alerts” phone number in our Favorites and then configured calls from Favorites to always come through, regardless of the hour.

Making a phone call with Twilio was just as easy as sending a text:

Note that when the app called us, it just played the default audio from Twilio, a rickroll. We didn’t actually need to have it say anything because we would know that when we got the call, we should just check the website.

The call

For about a week, fnnch and I patiently waited to be notified of any updates.

I was at the gym, in the middle of doing some crunches, when I got the call.

A fake screenshot because I was too nervous at the time to take one.

Eek! I quickly opened the website on my phone.

At this point both fnnch and I discovered that this was not, in fact, a drop.

Instead visitors could add an item from the shop to their cart with a short message and would be selected at random to make the purchase.

The result

First, I’m thrilled my little app worked!

And honestly I’m relieved this wasn’t a race to visit the website. Banksy seems too cool for that.

I also realized that I can forget how much fun it is to work on a new coding challenge. It’s creative and rewarding to quickly build an app from scratch to solve a problem.

Am I sad to not get a million dollar artwork? A little, but not too sad. The journey was the reward.

W̶h̶y̶ does art matter?

I wrote an app to check grossdomesticproduct.com every minute and call me if it changed. It worked, but I didn’t get a painting. I’m not disappointed. It was fun just to make something.

Here’s the full source code.

Leah Culver

Written by

Co-founder and CTO of Breaker. 🍹 Co-author of OAuth and oEmbed. I like both cats and dogs.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade