Mama needs a new bag: Puppeteer + AWS
Well, it’s that time of year. Christmas, the time of year I surprise my wife with a new purse. I like nice things and she deserves the best. She had told me some time ago about the purse she would love to get, and so that is the bag I am trying to purchase. It is also the reason I am writing this article.
Flashback, a few weeks ago I went online and found the bag isn’t in stock; however my wife found many strangers bragging about how they’d just purchased the very same bag. So I called the HQ. I was told the bag is restocked periodically and that I can choose the ‘notify me’ option on the website. I hung up and went searching, only to find that there is NO ‘notify me’ option.
Flash Forward a lil’ bit, here we are. I basically built my own ‘notify me’ application.
Tech used:
- Node
- Puppeteer
- AWS SNS
- Crontab (Mac)
*FYI: I chose crontab instead of cloud functions because the website aggressively blocks non-residential ip addresses … even VPN’s are blocked!*
The GitHub link: here
Why Node?
Node is like a old friend to me. Javascript and Node just align with my way of thinking about matters at hand. When I am trying a new idea out, I always ask node the way forward. I am not a hotshot whiz developer, I don’t care about which langauge, I always start with node and then look elsewhere if it doesn’t fit the job. I am not afraid to sink the whole damn ship when learning something new. Another reason I chose Node is Winston for logging. Winston is so good! Easy to implement and the sky’s the limit.
Why puppeteer?
Puppeteer is Google’s own headless web driver. It’s a wonderful tool for working in Node. I could have chose others; i.e. Selenium; but I’ve always wanted to play around with Puppeteer, and this was my chance. Also, this application has been deployed as a serverless function in AWS Lambda and I can talk about figuring that out in another article, but again, the website I sought is not happy with non-residential ip addresses.
Why AWS SNS?
I wanted to be informed of the bag’s availability via text messaging, and while I am not a great at being alert to text messages, I am even worse at being alert to emails. Emails are out! In all, AWS topics and subscriptions are very simple. I chose a standard SMS implementation to a topic I had created for this very application, and when my bag is available, a message is published to my designated topic, and I receive text on my iphone.
Why Crontab?
Crontab is something I just learned about when I realized my access to the website is being blocked by ip address recognition. So, I am running my macbook at all hours, and calling the application to run periodically. Crontab is very simple. The main lesson here, is on a macbook you need to give the cron program full disk access, and then all will be working smoothly.
In the end
Have I gotten the purse? NO! It’s been brutal. Missing the text messages informing me of my bag’s availability is disheartening, it is as though the company knows what I have been up to and therefore has been mocking me. Thus far, I have missed three opportunities to purchase the coveted bag, by being asleep. What keeps me going? The application works like a charm. I’ve even expanded to other regions and other bags.
Hope this helps you get your special someone that special gift this holiday season. Merry Christmas and Happy holidays.