issanholovibrant.com
San Holo is one of my favourite artists. One of his projects is Stay Vibrant . He places a percentage sign in his name on twitter as a mood tracker. Inspired by sites like isitchristmas.com and, the more useful, kanikeenkortebroekaan.nl I wanted to make a website that reported whether he was feeling vibrant or not based on that percentage.
httpx and regex
I made the first version with
httpx
and the built in regex library. The script makes a GET
request to the twitter page and extracted the percentage with a regex. It looked like this.
|
|
As you can see that’s not a lot of code! I hosted this first version on gitlab pages and updated with gitlab ci. There were some problems with this setup, namely that gitlab pages was not reliable enough for me. It sometimes took timing out first before the site worked. When I got a VPS I moved it to that and updated the website with cron.
Twitter breaks GET
At some point twitter requires JavaScript to access the page and no longer sends rendered html when doing GET
requests. I read on hackernews that it still worked when using the user-agent of the google bots. I added that to my script and it worked again.
|
|
The user-agent stops working
Somewhere in the last two months the user-agents stops working too. Not to be outdone by twitter I wanted to find a fix. The main issue is needing javascript execution. I ended up running a headless browser with python-playwright . It’s insane that I need to run a whole browser to get a percentage from a webpage, and playwright installs three of them!
I couldn’t get it working how I wanted, I had to insert a flat five-second timeout for content to render. I might come back to it to do it properly when it inevitably breaks again.
|
|
As you can see, the script has gotten hackier with time. At this point I see it as a challenge to keep this script working no matter what. Please visit issanholovibrant.com to see how San Holo is doing, and don’t forget to stay vibrant ⬆✨.