Since the new Xbox Series X launch last year, it has been almost impossible to get your hands on one. It is continually out of stock at all the major retailers.
To check if it is in stock, we typically visit a retailer’s website. But we don’t want to go and check every day or, more importantly, every 10 minutes. But if we had the right software solution, we could just automate this process.
But how to load the page and check for “Sold out”. The easiest way is to just do an HTTP GET and to retrieve the page’s content. The problem with most modern websites is that it isn’t that easy. You often need to render the page to see specific content, such as the “Sold out” text below.
So how can we do that? We’ll start with Puppeteer, a headless version of Google’s Chrome browser. With Puppeteer, we can load the page and check for that “Sold out” text.
To use Puppeteer, you will need to install the npm module for it.
npm install puppeteer
After we have Puppeteer installed, we need to write a little JS that we will run using node.
To run the program, we can use the following command.
Now we have some code that will tell us if Target has an Xbox Series X in stock. But at this point, we still must continually run our app and watch the output. In Part 2 of this series, we will set ourselves up to use Twilio and SMS to make the website content easier to monitor.