A Node.js app for monitoring trends in retail prices at Kesko's grocery stores (e.g. K-Market).
The app lets you log prices on given products and view their changes over time.
Try a live sample of hs with mock data here.
- Easy to log prices, automatable with e.g. cron
- Data can be logged into a Postgres database or standalone JSON files
- Clean, simple web interface for viewing logged data in a browser
The app is currently work in progress.
The logger uses Puppeteer to fetch price data from a given K store via the K-Ruoka website, maintaining the information in a JSON database.
The server generates and serves a web page for displaying the database's contents to a client browser.
You can find a simple sample of hs under sample/local/. It monitors the prices of three products sold at K-Market Erottaja.
Hs uses a config file to set certain operating parameters. The sample's config is loaded from sample/local/hs.json.
||A string that will be displayed in the header of the generated web interface. Can use HTML formatting.|
||An object that provides information about the database to be used for storing logged data.|
||Identifies whether to use a flat-file (
||For flat-file databases. Identifies the root directory into which the database's files will be placed.|
||An array naming the stores for which prices will be logged; using the IDs of K-Ruoka.fi (e.g.
||An array identifying the products whose prices will be logged.|
To fetch and log the current prices of the three products, run
$ node ./src/fetch.mjs ./sample/local/hs.json from the repo's root. By default, the fetch script has a generous cool-down period for network requests, so this should take about 15 seconds to complete.
Once the fetcher has completed, you should see a new directory called
./sample/local/files. The directory should contain three JSON files, one for each product.
Depending on your needs, you could set up a cron job to run the logger at given intervals, e.g. once per day.
To view the data that you're logging, start hs's web server by running
$ node ./src/serve.mjs ./sample/local/hs.json 8115 from the repo's root.
Once the server is running, point your browser to
http://localhost:8115, and you should see the three products appear.
The web interface doesn't yet support segregating the view by store, so even if you're logging prices across multiple stores, the results will all be lumped together on the page.
A note about dependencies
package.json currently combines the dependencies of both the logger and the server; but one or the other alone needs only some of the dependencies. For example, the server only depends on
pg, and only if using a Postgres database.
In the future, the project might be split into multiple packages. But for now, if you want to avoid installing unnecessary dependencies, you can prune the package file as needed for your purposes.