added support for ep.nl

This commit is contained in:
Nick Leeman 2021-03-26 15:53:13 +01:00
parent e8d271edc6
commit e418b5dc34
2 changed files with 23 additions and 2 deletions

View File

@ -32,7 +32,8 @@ import {
HuisdierExpress, HuisdierExpress,
HondenBed, HondenBed,
Coolblue, Coolblue,
WifiMedia WifiMedia,
Ep
} from "./modules/websites"; } from "./modules/websites";
// Globals // Globals
@ -46,7 +47,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.coolblue.nl/product/829953/cardo-scala-rider-freecom-4-plus-single.html")); console.log(await crawlProductStock("https://www.ep.nl/products/sony-kd-l32we610-hd-led-tv/27658/"));
} }
async function start() { async function start() {
@ -283,6 +284,9 @@ async function crawlProductStock(url: string) {
case "wifimedia.eu": case "wifimedia.eu":
return [domain, page.url(), await WifiMedia.check(html)]; return [domain, page.url(), await WifiMedia.check(html)];
case "ep.nl":
return [domain, page.url(), await Ep.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!`);

View File

@ -527,3 +527,20 @@ export namespace WifiMedia {
} }
} }
export namespace Ep {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($(".product__info").find(".is-green").html()) {
return true;
}
return false;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}