A small and simple DOM detection changer for when you're in desperate need of a new Nvidia graphics card or anything
else that tickles your pickle.
Overview
- ✅ Monitor multiple URLs to detect DOM changes.
- ✅ Use a valid crontab selector to run monitoring jobs.
- ✅ Integrates with SMTP email and Slack.
- ✅ Easy use with Docker or running on bare metal.
- ✅ Comprehensive HTTP client that follows redirects.
- ✅ Extremely lightweight with few dependencies.
Why?
In the ever-changing world of online shopping, sometimes it's merely impossible to get your favorite product. This tiny
package allows you to monitor changes on the DOM to detect when a element has changed. It's not just limited to
products, but anything you like.
pages:
- url: https://test.com # URL to monitor
selector: .class-selector # DOM selector
schedule: "* * * * *" # Run every minute
notify:
email:
address: smtp.gmail.com
port: 587
user: hello@hello.com
password: password
receivers:
- me@myemai.com
slack:
token: token
channel_id: id
Installation
Informer can either be run in Docker or using the prebuilt binaries in the releases section, information on both methods
are shown below.
Binary
The following platforms that are supported are listed below. The examples used are for Darwin amd64, please change the
release name if you intend to use a different OS.
Darwin amd64
Darin arm64
Linux amd64
Linux arm64
Windows amd64
Download the Binary
Head over to the releases page and download the relevant
release to your operating system.
$ wget "https://github.com/ainsleyclark/stock-informer/releases/download/v0.0.1/informer_0.0.1_darwin_amd64.tar.gz"
> ‘informer_0.0.1_darwin_amd64.tar.gz’ saved
Unzip
$ tar -xf informer_0.0.1_darwin_amd64.tar.gz && cd informer
Configuration
Change config.example.yml
to config.yml
and change to your liking.
Run
$ ./informer -path=/path/to/config/config.yml
> [INFORMER] 2022-12-14 08:14:05 | LOG | [INFO] | [msg] Loading Configuration
> [INFORMER] 2022-12-14 08:14:05 | LOG | [INFO] | [msg] Booting Informer
Docker
Docker images are located at
the packages page. Be sure to use the
latest version number when pulling the image.
Pull the Docker Image
Head over to the packages page and pull
the latest image version to your local machine.
$ docker pull ghcr.io/ainsleyclark/stock-informer:0.0.1
Run the Image
Running the image requires two required arguments/flags.
- The path to the configuration file stored on the local machine, with the arg
v
.
- The
-path
argument for the binary which should correlate to the path passed in. This will allow you to attach your
configuration file from your local machine to the docker image.
$ docker run -it --rm -v /path/to/config/config.yml:/mnt/config.yml ghcr.io/ainsleyclark/stock-informer:0.0.1 -path=/mnt/config.yml
> [INFORMER] 2022-12-14 08:14:05 | LOG | [INFO] | [msg] Loading Configuration
> [INFORMER] 2022-12-14 08:14:05 | LOG | [INFO] | [msg] Booting Informer
Configuration
The configuration for the informer is super simple, you can see it below. The yaml file can be named whatever you want,
but it must follow some conventions.
pages:
- url: https://test.com # URL to monitor
selector: .class-selector # DOM selector
schedule: "* * * * *" # Run every minute
notify:
email:
address: smtp.gmail.com
port: 587
user: hello@hello.com
password: password
receivers:
- me@myemai.com
slack:
token: token
channel_id: id
Pages
Pages is a collection of URLs to monitor. The URL is the page you want to monitor, the selector should be a valid CSS
selector and the schedule is a crontab expression defining when the scrape should happen.
Notifiers
Currently, SMTP email and Slack notifiers are supported, but there are more to come. The settings for each notifier are
self explanatory but all required.
Roadmap
- Add
App Debug
to the configuration to hide or show the log debug messages.
- Add more notifiers, github.com/nikoksr/notify has been used as a package and
there are an abundance of notification methods that can be used.
- Call cron monitoring recursively to eradicate waiting for new change.
- Validation on configuration struct.
Development
To set up the application for development first, clone the repository.
git clone https://github.com/ainsleyclark/stock-informer.git
Run the setup command to install the necessary dependencies for Krang.
make setup
Makefile
Common commands are detailed in the Makefile
to list usage run:
make help
setup Setup dependencies
run Run
dist Creates and build dist folder
format Run gofmt
lint Run linter
test Test uses race and coverage
test-v Test with -v
cover Run all the tests and opens the coverage report
docker-clean Removes the docker image
docker-build Builds the docker image
docker-run Run the docker image
mock Generate mocks keeping directory tree
bench Runs benchmarks
doc Runs go doc
all Make format, lint and test
todo Show to-do items per file
help Display this help
Contributing
We welcome contributors, but please read the contributing document before making a pull request.
Credits
Shout out to the incredible Maria Letta for her excellent Gopher illustrations.
Licence
Code Copyright 2023 Stock Informer. Code released under the MIT Licence.