added wifimedia support
This commit is contained in:
parent
8e52c437ef
commit
e8d271edc6
@ -31,7 +31,8 @@ import {
|
||||
Conrad,
|
||||
HuisdierExpress,
|
||||
HondenBed,
|
||||
Coolblue
|
||||
Coolblue,
|
||||
WifiMedia
|
||||
} from "./modules/websites";
|
||||
|
||||
// Globals
|
||||
@ -280,6 +281,9 @@ async function crawlProductStock(url: string) {
|
||||
case "hondenbed.nl":
|
||||
return [domain, page.url(), await HondenBed.check(html)];
|
||||
|
||||
case "wifimedia.eu":
|
||||
return [domain, page.url(), await WifiMedia.check(html)];
|
||||
|
||||
default:
|
||||
console.error(`-- ${domain} is not an available website module! Can't check stock!`);
|
||||
return [domain, page.url(), false];
|
||||
|
@ -509,3 +509,21 @@ export namespace Coolblue {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user