Search & show listings

This commit is contained in:
Edin Dazdarevic
2017-03-31 14:31:56 +02:00
parent c32e49e6c3
commit d6c2e857d0
16 changed files with 1598 additions and 35 deletions

View File

@@ -4,9 +4,6 @@ let fetch = require('node-fetch');
let cheerio = require('cheerio');
let fs = require('fs');
const pagesToTake = 10;
export default class OlxCrawler {
constructor(fromPage = 0, toPage = 10, maxResults = 1000) {
@@ -69,6 +66,7 @@ export default class OlxCrawler {
longDescription: descriptions.last().text(),
lat,
lng,
loc: [parseFloat(lat), parseFloat(lng)],
images
};
@@ -85,10 +83,10 @@ export default class OlxCrawler {
console.log('Starting to index page: ' + pageNr);
const url = `http://www.olx.ba/pretraga?vrsta=samoizdavanje&sort_order=desc&kategorija=23&sort_po=datum&kanton=9&stranica=${pageNr}`;
const res = await fetch(url);
const body = await res.text();
const $ = cheerio.load(body);
const hrefs = [];
const res = await fetch(url);
const body = await res.text();
const $ = cheerio.load(body);
const hrefs = [];
const results = {};
$('#rezultatipretrage').find('.listitem').each((i, elem) => {
@@ -135,5 +133,3 @@ export default class OlxCrawler {
}
}
//indexSingle('http://www.olx.ba/artikal/23198642/trosoban-stan-centar-josipa-vancasa/');