Files
old-web/app/crawler/crawl.js
2019-09-18 15:32:48 +02:00

36 lines
852 B
JavaScript

"use strict";
/*
Entry point for crawling functionality
All communication between crawlers and savers is here
All environment specific configuration is read here and
passed to the crawlers and savers.
*/
require("dotenv").config();
const OlxCrawler = require("./specific/olx");
const { OLX_CONFIG } = require("./crawlerConfig");
const PostgresSaver = require("./savers/postgres");
const crawlers = [
new OlxCrawler(
OLX_CONFIG.OLX_START_PAGE,
OLX_CONFIG.OLX_END_PAGE,
OLX_CONFIG.OLX_MAX_RESULTS_PER_PAGE,
[new PostgresSaver()],
OLX_CONFIG.OLX_CRAWLER_AD_TYPE,
OLX_CONFIG.OLX_CRAWLER_AD_CATEGORIES
)
];
async function crawlAll() {
for (let crawler of crawlers) {
try {
await crawler.crawl();
} catch (e) {
console.log("Error crawling. Trying next crawler! ", e);
}
}
}
crawlAll();