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,
|
HondenBed,
|
||||||
Coolblue,
|
Coolblue,
|
||||||
WifiMedia,
|
WifiMedia,
|
||||||
Ep
|
Ep,
|
||||||
|
Kinq
|
||||||
} from "./modules/websites";
|
} from "./modules/websites";
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
@ -42,12 +43,12 @@ let sitemapUrl: string = "";
|
|||||||
let allProducts: Array<any> = [];
|
let allProducts: Array<any> = [];
|
||||||
let allBlogUrls: Array<any> = [];
|
let allBlogUrls: Array<any> = [];
|
||||||
|
|
||||||
// debugStart();
|
debugStart();
|
||||||
start();
|
// start();
|
||||||
|
|
||||||
async function debugStart() {
|
async function debugStart() {
|
||||||
browser = await puppeteer.launch({ headless: false });
|
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() {
|
async function start() {
|
||||||
@ -287,6 +288,9 @@ async function crawlProductStock(url: string) {
|
|||||||
|
|
||||||
case "ep.nl":
|
case "ep.nl":
|
||||||
return [domain, page.url(), await Ep.check(html)];
|
return [domain, page.url(), await Ep.check(html)];
|
||||||
|
|
||||||
|
case "kinq.nl":
|
||||||
|
return [domain, page.url(), await Kinq.check(html)];
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.error(`-- ${domain} is not an available website module! Can't check stock!`);
|
console.error(`-- ${domain} is not an available website module! Can't check stock!`);
|
||||||
|
@ -536,6 +536,26 @@ export namespace Ep {
|
|||||||
return true;
|
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;
|
return false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user