-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (23 loc) · 1.07 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Generated by CoffeeScript 1.6.3
(function() {
var EbkScraper, Mailer, config, ebk, mailer, sendIds,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
EbkScraper = require('./ebkScraper');
Mailer = require('./mailer');
config = require('./config/berlin.json');
ebk = new EbkScraper(config.scrapingOpts);
mailer = new Mailer(config.mail);
sendIds = [];
ebk.on('match', function(offer) {
var message, subject, _ref;
if (_ref = offer.id, __indexOf.call(sendIds, _ref) >= 0) {
return;
}
subject = "" + offer.district + " -> " + offer.rooms + " Zi -> " + offer.size + " qm -> " + offer.netRent + " Eur";
message = "" + offer.href + "\n\n" + offer.phone;
sendIds.push(offer.id);
return mailer.send(subject, message, console.log);
});
setInterval(ebk.scrape, config.scrapInterval * 60 * 1000);
console.log("service is up and runing\nfirst scraping action starts in " + (config.scrapInterval * 60) + " seconds");
}).call(this);