Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const nodemailer = require('nodemailer');
- const request = require('request');
- var transporter = nodemailer.createTransport({
- host: 'smtp.gmail.com',
- port: 587,
- secure: false,
- auth: {
- user: 'login',
- pass: 'password'
- }
- });
- var mailOptions = {
- from: '"Forman" <example@gmail.com>',
- to: 'example@gmail.com',
- subject: 'Wyniki egzaminu z matemayki dyskretnej',
- html: '<a>http://www.cs.put.poznan.pl/pformanowicz/students.html</a>'
- };
- function notify()
- {
- transporter.sendMail(mailOptions, (error, info) => {
- if (error) {
- return console.log(error);
- }
- console.log(`Mail sent to ${mailOptions.to}`);
- });
- }
- const options = {
- url: 'http://www.cs.put.poznan.pl/pformanowicz/students.html',
- method: 'HEAD'
- };
- var lastModified;
- request(options, (err, res, body)=>{
- lastModified = res.headers['last-modified'];
- });
- var id = setInterval(()=>{
- var tmp;
- request(options, (err, res, body)=>{
- tmp = res.headers['last-modified'];
- console.log("request made");
- if(lastModified != tmp)
- {
- notify();
- clearInterval(id);
- }
- });
- }, 5000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement