added support for kabels.nl
This commit is contained in:
parent
7ff8b26a61
commit
3a1f6a0f27
@ -36,7 +36,8 @@ import {
|
|||||||
Ep,
|
Ep,
|
||||||
Kinq,
|
Kinq,
|
||||||
Maxiaxi,
|
Maxiaxi,
|
||||||
FotoDeVakman
|
FotoDeVakman,
|
||||||
|
Kabels
|
||||||
} from "./modules/websites";
|
} from "./modules/websites";
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
@ -50,7 +51,7 @@ 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.fotodevakman.nl/sony-a7-iii-body-sony-sel-sel-28-60mm-f4-5-6"));
|
console.log(await crawlProductStock("https://www.kabels.nl/nl_nl/ewent-ew3240-draadloze-multi-connect-muis-600-2400-dpi-zwart-34863350.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
@ -299,6 +300,9 @@ async function crawlProductStock(url: string) {
|
|||||||
|
|
||||||
case "fotodevakman.nl":
|
case "fotodevakman.nl":
|
||||||
return [domain, page.url(), await FotoDeVakman.check(html)];
|
return [domain, page.url(), await FotoDeVakman.check(html)];
|
||||||
|
|
||||||
|
case "kabels.nl":
|
||||||
|
return [domain, page.url(), await Kabels.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!`);
|
||||||
|
@ -619,4 +619,22 @@ export namespace FotoDeVakman {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace Kabels {
|
||||||
|
export async function check(html: string) {
|
||||||
|
try {
|
||||||
|
const $ = cheerio.load(html);
|
||||||
|
|
||||||
|
if ($(".product-info-main").find(".stock .available").first()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
console.error(`Error occured during stock check!`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user