The scalpers are real, people are struggling to get hold of PlayStation 5’s – First world problems eh! In this post I will go through how to create a simple bot that will check for stock replenishment at certain stores.
Looking at the many stores that sell the console, I came across Argos and it didn’t take me long to decipher their URL variations. They make use of product numbers and so a 7 digit unique product number is assigned to every item that is potentially up for sale. The URL for a Chad Valley 50 cm Large Lion Activity Toy is seen as:
The product ID for the PlayStation 5 console is 8349000 and so the URL for it would be http://www.argos.co.uk/product/8349000. Although at the time of writing this, the expected URL for the PlayStation 5 console redirects you the following.
The “oos” referring to the product being out of stock, using a Python script and a web driver we can visit the expected URL http://www.argos.co.uk/product/8349000 and simply look out for any redirects. If we get redirected we know its still out of stock, if the URL stays as expected we know to buy!
OriginalURL = 'https://www.argos.co.uk/product/8349000' driver = webdriver.Chrome("C:\Chromium\chromedriver.exe") driver.get(OriginalURL) driver.implicitly_wait(1)
Once there and we have waited for the page to load, we can snatch the current URL and compare.
CurrentUrl = driver.current_url if "/oos/" not in CurrentUrl: #Its in Stock #OR if CurrentUrl == OriginalURL: #Its in Stock