Improved results filtering by lat lng
This commit is contained in:
@@ -183,27 +183,24 @@ module.exports = class OlxCrawler {
|
||||
}
|
||||
|
||||
async crawl() {
|
||||
// TODO create URLS from db
|
||||
|
||||
const filteredResults = [];
|
||||
const realestateRequests = await allRERequest()
|
||||
const urls = this.createRequestUrls(realestateRequests);
|
||||
let results = await this.indexPages(urls, this.fromPage, this.toPage, this.maxResults);
|
||||
|
||||
for (const result of results) {
|
||||
console.log(result);
|
||||
for (const re1 of result) {
|
||||
if (re1.lat !== undefined) {
|
||||
console.log(re1.lat);
|
||||
if (re1.lat !== undefined && re1.lat !== null && re1.lat !== "") {
|
||||
const pointInsideBoundingBox = await findPointInsideBoundingBox([re1.lng, re1.lat]);
|
||||
console.log(pointInsideBoundingBox);
|
||||
|
||||
if (pointInsideBoundingBox[0].length !== 0) {
|
||||
filteredResults.push(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log(results);
|
||||
|
||||
|
||||
|
||||
return results;
|
||||
return filteredResults;
|
||||
}
|
||||
|
||||
createRequestUrls(realestateRequests) {
|
||||
@@ -218,8 +215,6 @@ module.exports = class OlxCrawler {
|
||||
const priceMin = "od=" + request.priceMin;
|
||||
const priceMax = "do=" + request.priceMax;
|
||||
|
||||
|
||||
|
||||
const olxUrl = "https://www.olx.ba/pretraga?" + realsestateType + "&id=2&stanje=0&vrstapregleda=tabela&sort_order=desc&" + region + "&" + municipality + "&" + priceMin + "&" + priceMax + "&vrsta=samoprodaja&" + sizeMin + "&" + sizeMax
|
||||
console.log(olxUrl);
|
||||
urls.push(olxUrl);
|
||||
|
||||
Reference in New Issue
Block a user