Added formated subject to bulk email

This commit is contained in:
Nedim Uka
2019-07-02 21:49:56 +02:00
parent 7f0b2d299e
commit b79a274f96
8 changed files with 120 additions and 18 deletions

View File

@@ -13,7 +13,7 @@ module.exports = class OlxCrawler {
this.maxResults = maxResults;
}
async indexSingle(url, email) {
async indexSingle(url, email, uuid) {
try {
const res = await fetch(url);
const body = await res.text();
@@ -81,6 +81,7 @@ module.exports = class OlxCrawler {
const parsedPrice = parsePrice(price);
console.log(location);
const locationArray = location.split(",");
const region = locationArray[0];
const municipality = locationArray[1];
@@ -88,6 +89,7 @@ module.exports = class OlxCrawler {
const data = {
realEstateType: this.getCategoryId(realEstateType),
email: email,
uuid: uuid,
olxId: olxId,
// category: category,
url,
@@ -138,7 +140,7 @@ module.exports = class OlxCrawler {
for (let i = 0; i < hrefs.length; i++) {
console.log(`indexing: ${hrefs[i]}`);
const singleData = await this.indexSingle(hrefs[i], olxUrl.email);
const singleData = await this.indexSingle(hrefs[i], olxUrl.email, olxUrl.uuid);
if (singleData) {
results.push(singleData);
@@ -223,7 +225,8 @@ module.exports = class OlxCrawler {
const olxUrl = {
url: `https://www.olx.ba/pretraga?${realsestateType}&id=2&stanje=0&vrstapregleda=tabela&sort_order=desc&${region}&${municipality}&${priceMin}&${priceMax}&vrsta=samoprodaja&${sizeMin}&${sizeMax}`,
email: request.email
email: request.email,
uuid: request.uniqueId
}
console.log(olxUrl.url);
urls.push(olxUrl);