added support for kinq.nl
This commit is contained in:
parent
e418b5dc34
commit
3314adf054
12
src/core.ts
12
src/core.ts
@ -33,7 +33,8 @@ import {
|
||||
HondenBed,
|
||||
Coolblue,
|
||||
WifiMedia,
|
||||
Ep
|
||||
Ep,
|
||||
Kinq
|
||||
} from "./modules/websites";
|
||||
|
||||
// Globals
|
||||
@ -42,12 +43,12 @@ let sitemapUrl: string = "";
|
||||
let allProducts: Array<any> = [];
|
||||
let allBlogUrls: Array<any> = [];
|
||||
|
||||
// debugStart();
|
||||
start();
|
||||
debugStart();
|
||||
// start();
|
||||
|
||||
async function debugStart() {
|
||||
browser = await puppeteer.launch({ headless: false });
|
||||
console.log(await crawlProductStock("https://www.ep.nl/products/sony-kd-l32we610-hd-led-tv/27658/"));
|
||||
console.log(await crawlProductStock("https://www.kinq.nl/humax-eye-hd-cloud-camera-duo-pack.html"));
|
||||
}
|
||||
|
||||
async function start() {
|
||||
@ -287,6 +288,9 @@ async function crawlProductStock(url: string) {
|
||||
|
||||
case "ep.nl":
|
||||
return [domain, page.url(), await Ep.check(html)];
|
||||
|
||||
case "kinq.nl":
|
||||
return [domain, page.url(), await Kinq.check(html)];
|
||||
|
||||
default:
|
||||
console.error(`-- ${domain} is not an available website module! Can't check stock!`);
|
||||
|
@ -536,6 +536,26 @@ export namespace Ep {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(`Error occured during stock check!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Kinq {
|
||||
export async function check(html: string) {
|
||||
try {
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
if ($(".product-detail-infomation").find(".stock")) {
|
||||
if ($(".product-detail-infomation").find(".stock").first().attr("style") == "color: #2ace48;") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user