From edca7f91afcf1b673d34534535ae8c58d4ef296d Mon Sep 17 00:00:00 2001 From: Naida Vatric Date: Thu, 27 Feb 2020 19:01:11 +0100 Subject: [PATCH] Commented checkup out and Prostor fetch changed. --- app/crawler/specificCrawlers/prostor.js | 16 ++++++++++------ app/services/notificationService.js | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/crawler/specificCrawlers/prostor.js b/app/crawler/specificCrawlers/prostor.js index 5690a4b..bf2c30a 100644 --- a/app/crawler/specificCrawlers/prostor.js +++ b/app/crawler/specificCrawlers/prostor.js @@ -4,6 +4,7 @@ const fetch = require("../../helpers/fetchWrapper"); const cheerio = require("cheerio"); const moment = require("moment-timezone"); const FormData = require("form-data"); +const nodeFetch = require("node-fetch"); const { AD_TYPE, @@ -197,7 +198,7 @@ class ProstorCrawler { // console.log("[PROSTOR] Scraping : ", url); try { - const adPageSource = await fetch(url, { + const adPageSource = await nodeFetch(url, { headers: { Cookie: prostorCookie } }); const body = await adPageSource.text(); @@ -427,7 +428,7 @@ class ProstorCrawler { } try { - const res = await fetch(url, { + const res = await nodeFetch(url, { headers: { Cookie: prostorCookie } }); const body = await res.text(); @@ -591,7 +592,7 @@ class ProstorCrawler { formData.append("email", PROSTOR_LOGIN.EMAIL); formData.append("password", PROSTOR_LOGIN.PASSWORD); - return fetch("https://prostor.ba/moj-prostor/prijava", { + return nodeFetch("https://prostor.ba/moj-prostor/prijava", { method: "POST", body: formData, headers: { Cookie: prostorCookie } @@ -618,9 +619,12 @@ class ProstorCrawler { }); } async getCookies() { - const getResponse = await fetch("https://prostor.ba/moj-prostor/prijava", { - headers: { Cookie: "" } - }); + const getResponse = await nodeFetch( + "https://prostor.ba/moj-prostor/prijava", + { + headers: { Cookie: "" } + } + ); const raw = getResponse.headers.raw()["set-cookie"]; const cookie = raw .map(datastring => { diff --git a/app/services/notificationService.js b/app/services/notificationService.js index 08138ca..9fd9954 100644 --- a/app/services/notificationService.js +++ b/app/services/notificationService.js @@ -136,7 +136,7 @@ const notifyRequestsWithDailyOption = async () => { }; const checkUpNotify = async () => { - const searchRequestsForCheckUp = await findAllRequestsForCheckUp(); + /* const searchRequestsForCheckUp = await findAllRequestsForCheckUp(); const asyncSendEmailActions = []; @@ -153,7 +153,7 @@ const checkUpNotify = async () => { searchRequest.notifiedAt = new Date(); searchRequest.save(); } - await Promise.all(asyncSendEmailActions); + await Promise.all(asyncSendEmailActions);*/ }; module.exports = { -- 2.47.3