This simple tool was created to query the quantities of certain products across all available SAQ branches.
Since SAQ doesn't provide any public API, the only way to obtain this data is by manually browsing through the site. An easy way to achieve this is to parse through the HTML page using a parser. However, since SAQ's product page doesn't load up the data for all stores at once, the need arises for a way to automate the process of clicking certain buttons on the product page in order to load the rest of the data.
This is where Selenium Web Driver comes into action. This framework allows me to create scripts that automate the aforementioned processes, as well as scraping data from a given page.
Please ensure that you have JRE and Google Chrome installed on your machine.
I have provided a script to facilitate the installation of Chromedriver in the released archive. You may also follow the instructions below to install it yourself.
- Install Homebrew
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | sh
- Install the Chromedriver package
brew cask install chromedriver
Run
java -jar saq-inventory-scraper-x.x.x.jar
The program will then prompt you for a url to the product page. e.g. https://www.saq.com/en/14252639
To save the outputs to CSV files, run the program with an additional argument:
java -jar saq-inventory-scraper-x.x.x.jar --saveFile
The program will prompt for a file name at each operation.
For macOS users, you can just run the provided scripts, which will automatically run the JAR file if your system meets the requirement.
I created this tool in July 2020, during which the tool worked perfectly for the product pages in SAQ. However, their website design may change in the future and break the tool. I try to keep up with the design whenever possible but there's no guarantee for it.