Skip to content

Parses torgi.gov.ru and sends email notifications

Notifications You must be signed in to change notification settings

ryzhak/torgi-alarm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Torgi alarm

Parses torgi.gov.ru and searches for new auctions. On new auction sends email notification to user.

How it works

  1. Parse auctions for each company via casperjs --ignore-ssl-errors=true run.js --companyId=COMPANY_ID --categoryId=CATEGORY_ID --inn=INN and save them to auctions/auctions_INN.json.
  2. Save auctions from auctions folder to DB via node save_to_db.js.
  3. Send email notifications for unsent emails via node send_email.js.
  4. Log date and number of auctions found for each company via node log.js.

How to deploy

  1. Install nodejs.
  2. Install phantomjs globally.
  3. Install casperjs globally.
  4. npm install
  5. Add db config file config.js to db/config/config.js:
const fs = require('fs');

module.exports = {
  development: {
    username: 'root',
    password: '',
    database: 'torgi_alarm',
    host: '127.0.0.1',
    dialect: 'mysql'
  },
  test: {
    username: "root",
    password: null,
    database: "database_test",
    host: "127.0.0.1",
    dialect: "mysql"
  },
  production: {
    username: "root",
    password: null,
    database: "database_prod",
    host: "127.0.0.1",
    dialect: "mysql"
  }
};
  1. Add env.js file to the root folder:
module.exports = {
	EMAIL_HOST: "smtp.yandex.ru", // smtp host
	EMAIL_USERNAME: "[email protected]", // from email
	EMAIL_PASSWORD: "password", // from password
	EMAIL_TARGET: "[email protected]" // send notifications to
};
  1. From db folder run migration via ../node_modules/.bin/sequelize db:migrate.
  2. From db folder run seed script(initial data) via ../node_modules/.bin/sequelize db:seed:all.

How to run

  1. Add a cron job that parses all companies and saves auctions to json files
casperjs --ignore-ssl-errors=true run.js --companyId=1 --categoryId=13 --inn=2312180144 && casperjs --ignore-ssl-errors=true run.js --companyId=2 --categoryId=8 --inn=2225153948
  1. Add a cron job that saves auctions from json files to DB, sends emails and logs found auctions
node save_to_db.js && node send_email.js && node log.js

How to add a new company

  1. Add company credentials to Companies DB table.
  2. Add company and category where it posts auctions to Targets DB table(this step is optional but may be used in the future).
  3. Add a new cron job that parses auctions for new company. Ex: casperjs --ignore-ssl-errors=true run.js --companyId=3 --categoryId=13 --inn=2312195782

About

Parses torgi.gov.ru and sends email notifications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published