This commit is contained in:
Nick Leeman 2023-06-20 15:39:04 +02:00
parent b8f77cbc58
commit 3b485e4da7

View File

@ -15,41 +15,6 @@ export namespace Template {
} }
export namespace FitnessKoerier {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('.product-list .stock-msg').find("[itemprop=availability]").attr("content") == "out_of_stock") {
return false;
} else {
return true;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace FitnessApparaat {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($('[itemprop="offers"]').find(".stock-red").length >= 1) {
return false;
} else {
return true;
}
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace BolCom { export namespace BolCom {
export async function check(html: string) { export async function check(html: string) {
try { try {
@ -78,49 +43,4 @@ export namespace BolCom {
} }
} }
export namespace WifiMedia {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
if ($("[itemprop=availability]").first().attr("content") == "http://schema.org/InStock") {
return true;
}
return false;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}
export namespace Maxiaxi {
export async function check(html: string) {
try {
const $ = cheerio.load(html);
let stock = false;
$('script[type="application/ld+json"]').each((index, element) => {
let json = JSON.parse($(element).html());
if (json["@type"]) {
if (json["@type"] == "Product") {
if (json["offers"][0]["availability"] == "http://schema.org/InStock") {
stock = true;
return;
}
}
}
});
return stock;
} catch (error) {
console.log(error);
console.error(`Error occured during stock check!`);
return false;
}
}
}