added support for kabels.nl
This commit is contained in:
parent
7ff8b26a61
commit
3a1f6a0f27
@ -36,7 +36,8 @@ import {
|
||||
Ep,
|
||||
Kinq,
|
||||
Maxiaxi,
|
||||
FotoDeVakman
|
||||
FotoDeVakman,
|
||||
Kabels
|
||||
} from "./modules/websites";
|
||||
|
||||
// Globals
|
||||
@ -50,7 +51,7 @@ start();
|
||||
|
||||
async function debugStart() {
|
||||
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() {
|
||||
@ -299,6 +300,9 @@ async function crawlProductStock(url: string) {
|
||||
|
||||
case "fotodevakman.nl":
|
||||
return [domain, page.url(), await FotoDeVakman.check(html)];
|
||||
|
||||
case "kabels.nl":
|
||||
return [domain, page.url(), await Kabels.check(html)];
|
||||
|
||||
default:
|
||||
console.error(`-- ${domain} is not an available website module! Can't check stock!`);
|
||||
|
@ -619,4 +619,22 @@ export namespace FotoDeVakman {
|
||||
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