Git Product home page Git Product logo

finki-scraper's Introduction

FINKI Scraper

Various scripts for scraping several FINKI (FCSE) services for the purpose of forwarding them to Discord using webhooks.

It's recommended, but not required to run this inside a Docker container.

Installation

For development purposes, be sure to run npm run prepare to install the Git pre-commit hooks.

Installation (Docker)

  1. git clone [email protected]:Delemangi/finki-scraper.git
  2. docker compose build

Installation (Normal)

  1. git clone [email protected]:Delemangi/finki-scraper.git
  2. npm install

Running

You may optionally pass arguments to the below commands to override which scrapers are run.

Running (Docker)

docker compose run scraper or docker compose run scraper s1 s2 ... sn

Running (Normal)

npm run start or npm run start s1 s2 ... sn

Server Mode

You can also run this app in server mode using npm run serve, which will boot up an Express based server which will open endpoints for receiving new announcements. In this mode, the app will only scrape new announcements whenever it receives a request to get them, instead of periodically. It is also possible to clear the cache to obtain the same announcements again, as well as to fetch all available scrapers. There is a separate Docker Compose configuration in docker-compose.server.yaml for running the app in server mode, and it exposes the port 3000 by default.

The exposed endpoints are:

  • GET /list to get all available scrapers,
  • GET /get/<name> to get all announcements from a certain service,
  • DELETE /delete to delete the cache of all services,
  • DELETE /delete/<name> to delete the cache of the announcements from a certain service,

where name corresponds to the name (key) in the configuration.

Config

Create a config folder and in it create config.json. Example:

{
  "successDelay": 600000,
  "errorDelay": 60000,
  "maxPosts": 20,
  "webhook": "<logging webhook url>",
  "sendPosts": true,
  "scrapers": {
    "announcements": {
      "strategy": "announcements",
      "link": "https://www.finki.ukim.mk/mk/student-announcement",
      "webhook": "<webhook url>",
      "role": "[role]",
      "enabled": true
    },
    "jobs": {
      "strategy": "jobs",
      "link": "https://www.finki.ukim.mk/mk/fcse-jobs-internships",
      "webhook": "<webhook url>",
      "role": "[role]",
      "enabled": true
    },
    "events": {
      "strategy": "events",
      "link": "https://finki.ukim.mk/mk/fcse-events",
      "webhook": "<webhook url>",
      "role": "[role]",
      "enabled": true
    },
    "projects": {
      "strategy": "projects",
      "link": "https://finki.ukim.mk/mk/fcse-projects",
      "webhook": "<webhook url>",
      "role": "[role]",
      "enabled": true
    },
    "SIC": {
      "strategy": "course",
      "link": "https://courses.finki.ukim.mk/mod/forum/search.php?id=263&words=&phrase=&notwords=&fullwords=&hfromday=1&hfrommonth=1&hfromyear=1&hfromhour=1&hfromminute=1&htoday=1&htomonth=1&htoyear=1&htohour=1&htominute=1&forumid=486&subject=&user=&perpage=25",
      "webhook": "<webhook url>",
      "role": "[role]",
      "cookie": "[cookie]",
      "enabled": true
    }
  }
}

Use the enabled property to control which scrapers will be activated on the next run.

More scrapers may be added in config.json, and each scraper should have its own scraper strategy implemented. The course scraper strategy may be reused for other Moodle courses.

finki-scraper's People

Contributors

delemangi avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.