add OLX scraper test NPM script

This commit is contained in:
Bilal Catic
2019-10-18 09:14:08 +02:00
parent 2baf26db1c
commit 67a7223a3a
2 changed files with 19 additions and 1 deletions

View File

@@ -12,7 +12,8 @@
"docker-start": "docker start pg_marketalerts", "docker-start": "docker start pg_marketalerts",
"docker-stop": "docker stop pg_marketalerts", "docker-stop": "docker stop pg_marketalerts",
"crawl": "cd app/crawler && node npmCrawl.js", "crawl": "cd app/crawler && node npmCrawl.js",
"test-search": "cd test && node searchTest.js" "test-search": "cd test && node searchTest.js",
"test-olx-scraper": "cd test && node olxScrapeTest.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

17
test/olxScrapeTest.js Normal file
View File

@@ -0,0 +1,17 @@
"use strict";
const olxCrawler = require("../app/crawler/specific/olx");
const urlToScrape = process.argv[2] || undefined;
if (urlToScrape) {
const crawler = new olxCrawler();
(async () => {
const data = await crawler.scrapeAd(urlToScrape);
console.log(data);
})();
} else {
console.log("No URL to scrape. Use like this : ");
console.log("npm run test-olx-scraper -- URL_TO_SCRAPE");
}