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.
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”.
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!
Making the app
Thanks to jet lag, I woke up at 3 am. When better to start hacking?
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.
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.
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.
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.
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.
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.
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.