handle failed page fetch
This commit is contained in:
@@ -202,6 +202,10 @@ class AktidoCrawler {
|
|||||||
const body = await adPageSource.text();
|
const body = await adPageSource.text();
|
||||||
const $ = cheerio.load(body);
|
const $ = cheerio.load(body);
|
||||||
|
|
||||||
|
if (body.indexOf('<html') === -1) {
|
||||||
|
throw { message: 'Failed to fetch page !' }
|
||||||
|
}
|
||||||
|
|
||||||
const mapElementParent = $(".box-map").parent();
|
const mapElementParent = $(".box-map").parent();
|
||||||
const scriptElement = $("script", mapElementParent);
|
const scriptElement = $("script", mapElementParent);
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -215,6 +215,10 @@ class ProstorCrawler {
|
|||||||
const body = await adPageSource.text();
|
const body = await adPageSource.text();
|
||||||
const $ = cheerio.load(body);
|
const $ = cheerio.load(body);
|
||||||
|
|
||||||
|
if (body.indexOf('<html') === -1) {
|
||||||
|
throw { message: 'Failed to fetch page !' }
|
||||||
|
}
|
||||||
|
|
||||||
// link contains part of the URL in the format of : /prodaja/stan/stup/9556
|
// link contains part of the URL in the format of : /prodaja/stan/stup/9556
|
||||||
// general form is : /actionType/realEstateType/location/realEstateID
|
// general form is : /actionType/realEstateType/location/realEstateID
|
||||||
// linkParts contains : ['', 'actionType', 'realEstateType', 'location', 'realEstateID']
|
// linkParts contains : ['', 'actionType', 'realEstateType', 'location', 'realEstateID']
|
||||||
|
|||||||
@@ -202,6 +202,10 @@ class RentalCrawler {
|
|||||||
const body = await adPageSource.text();
|
const body = await adPageSource.text();
|
||||||
const $ = cheerio.load(body);
|
const $ = cheerio.load(body);
|
||||||
|
|
||||||
|
if (body.indexOf('<html') === -1) {
|
||||||
|
throw { message: 'Failed to fetch page !' }
|
||||||
|
}
|
||||||
|
|
||||||
const mapElementParent = $(".box-map").parent();
|
const mapElementParent = $(".box-map").parent();
|
||||||
const scriptElement = $("script", mapElementParent);
|
const scriptElement = $("script", mapElementParent);
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -220,12 +220,16 @@ class SaljicCrawler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async scrapeAd(url, adType) {
|
async scrapeAd(url, adType) {
|
||||||
console.log("[SALJIC] Scraping : ", url);
|
// console.log("[SALJIC] Scraping : ", url);
|
||||||
try {
|
try {
|
||||||
const adPageSource = await fetch(url);
|
const adPageSource = await fetch(url);
|
||||||
const body = await adPageSource.text();
|
const body = await adPageSource.text();
|
||||||
const $ = cheerio.load(body);
|
const $ = cheerio.load(body);
|
||||||
|
|
||||||
|
if (body.indexOf('<html') === -1) {
|
||||||
|
throw { message: 'Failed to fetch page !' }
|
||||||
|
}
|
||||||
|
|
||||||
// No information for status ex. PRODAN
|
// No information for status ex. PRODAN
|
||||||
const status = AD_STATUS.STATUS_NORMAL;
|
const status = AD_STATUS.STATUS_NORMAL;
|
||||||
//Extracting agency ID from url
|
//Extracting agency ID from url
|
||||||
|
|||||||
Reference in New Issue
Block a user