Skip to main content

All tools you need to interact with nood.

Project description

nood - Notifications On Demand

A wrapping library for web crawlers automation.

The main objective of this service is to easily enable developers to build and run monitors. Basically, developers only have to write a download function and a corresponding parse function to run a monitor.

Prerequisites

To use nood, you need an API key. Please join our Discord and contact turner#0069.

We also encourage you to use pm2 (click here for more information) to run your monitors.

Installation

Install nood with pip.

pip install nood

Configuration

The configuration for each monitor is stored in a json file. The default directory for the config file is the same as the monitor's script directory. The default name for the config file is config.json, but can be configured individually.

{
  "monitor_id": 1234,
  "api_key": "abcdefg1234567890",
  "proxies": [
    "ip:port:user:pass"
  ],
  "urls": [
    "https://example.com/1",
    "https://example.com/2"
  ],
  "pids": [
    "example-pid-1",
    "example-pid-2"
  ]
}

Example Scraper with Config

For each monitor, the Scraper and Parser class must be defined. The monitoring logic is managed in the Monitor class which is defined by nood.

import requests

from nood import monitor, objects


class MMSScraper(monitor.Scraper):
    def __init__(self, url: str, **kwargs):
        super(MMSScraper, self).__init__(url=url, **kwargs)

    def download(self) -> requests.Response:
        headers = {
            'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) '
                          'AppleWebKit/537.36 (KHTML, like Gecko) '
                          'Chrome/108.0.0.0 Safari/537.36'
        }
        response = self._s.get(
            url=self.url,
            proxies=self.get_static_proxy(),
            headers=headers
        )

        return response


class MMSParser(monitor.Parser):
    def __init__(self):
        super().__init__()

    def parse(self, *, response: requests.Response):
        name = response.text.split('<title data-rh="true">')[1].split("|")[0]
        turl = response.text.split('"og:image" content="')[1].split('"')[0]
        variants = []
        if "</div>In den Warenkorb</button>" in response.text:
            variants.append(objects.Variant(value="OS"))

        return objects.Product(
            url=response.url,
            name=name,
            variants=variants,
            thumbnail_url=turl
        )


if __name__ == "__main__":
    monitor.Monitor.launch_tasks(scraper=MMSScraper, parser=MMSParser)

The configuration file for Mediamarkt would look like this:

{
  "monitor_id": 1234,
  "api_key": "abcdefg1234567890",
  "proxies": [],
  "urls": [
    "https://www.mediamarkt.de/de/product/_apple-airpods-mit-ladecase-2-generation-2539111.html"
  ],
  "pids": []
}

To run and keep track of the monitoring script with pm2, you can use the following commands:

pm2 start mms.py
pm2 monit

To stop the script, use

pm2 stop mm2.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nood-0.1.12.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

nood-0.1.12-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file nood-0.1.12.tar.gz.

File metadata

  • Download URL: nood-0.1.12.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.17 Linux/5.15.0-1040-azure

File hashes

Hashes for nood-0.1.12.tar.gz
Algorithm Hash digest
SHA256 9547842b8e216533af4e286c70ea02afbbb048f036e86c887cd288781317a6f5
MD5 2ede13cd836ec0544588c00edef6133d
BLAKE2b-256 4cf7791331e7ed5a415d48646caa811feb6331d3d486d62c87ac5b2c36958306

See more details on using hashes here.

File details

Details for the file nood-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: nood-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.17 Linux/5.15.0-1040-azure

File hashes

Hashes for nood-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 03d203791d523be0c55d1b2d982cf334c4fd072a9583c03976b1d96ddf1a4719
MD5 c42be40105b364add766b563cde098f7
BLAKE2b-256 43053ce37c192f999c67a84810f84bec448de2f9c63b038ceff52a832d30f417

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page