Code Monkey home page Code Monkey logo

stock-informer's Introduction

Informer Logo

made-with-Go Go Report Card Maintainability Test codecov go.dev reference

πŸ“ˆ Stock Informer

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: [email protected]
    password: password
    receivers:
      - [email protected]
  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: [email protected]
    password: password
    receivers:
      - [email protected]
  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.

stock-informer's People

Contributors

ainsleyclark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stock-informer's Issues

FR: Support client side rendering for detecting changes

Thanks for a great package. I had been using it for awhile before realizing that the page I was tracking rendered 90% complete server side except for stock information which was filled in client side immediately post load.

Solving this problem is a lot more heavy weight but I'm thinking of trying something like https://github.com/go-rod/rod and using that to load the page and then extract the DOM to pass to the rest of the app...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.