-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.js
30 lines (21 loc) · 909 Bytes
/
main.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
const config = require('config');
const scrape = require("./controllers/scrape.js");
const parse = require("./controllers/parse.js");
const mail = require("./controllers/mail.js");
(async () => {
const searches = config.get('Searches');
const searchResult = {"items": {}, "count": 0}
for await (const search of searches){
try {
const source = await scrape.getSource(search);
const items = await parse.getSearchResults(source.data);
const newItems = await parse.getNewItems(items);
console.log(newItems)
searchResult['items'][`${search.term} - ${search.location}`] = newItems;
searchResult['count'] += newItems.length
} catch (err) {
searchResult['items'][`ERROR: ${search.term} - ${search.location}`] = [];
}
}
await mail.send(searchResult);
})();