We wanted to adopt a kitten from the Oregon Humane Society. In these days of the pandemic, their adoption process has changed and you’re only allowed to apply online. So we checked their website regularly. That’s when we noticed that demand is very high these days so the window to apply was very short. New kittens would get posted but by the time we noticed and applied, they would already have been spoken for. This went on for a week or so.

So I did what any programmer might do, I implemented a script to detect when new kittens are posted. It was run every five minutes for about three weeks. Now it has been retired with the arrival of Mr. Momo a few weeks ago.

The script flow is pretty straightforward:

  • Retrieve the page that lists kittens.
  • Use some regular expressions to get the relevant data out.
  • Open a local JSON file of saved kittens from the previous run so that the new kittens can be identified.
  • If there are new kittens, use Pushcut to send a notification to my phone (and watch).
  • If the notification is successful, save the list of currently available kittens in a local JSON file for referencing in the next run.

It was loaded as a launchd service on my always-on Mac, which I manage using LaunchControl.app.

Here’s the script in its entirety: