added website support
This commit is contained in:
parent
9cfda0e5f5
commit
22aa81f2ee
46
src/core.ts
46
src/core.ts
@ -15,7 +15,18 @@ import {
|
||||
PerfectBody,
|
||||
Alternate,
|
||||
Expert,
|
||||
Silvergear
|
||||
Silvergear,
|
||||
AlsaNature,
|
||||
Dobey,
|
||||
EzyDog,
|
||||
K9Shop,
|
||||
OnlineHondenSpeciaalZaak,
|
||||
MacroVet,
|
||||
PetDuka,
|
||||
ZooEnzo,
|
||||
PetsOnline,
|
||||
PetsPlace,
|
||||
ThePetEmpire
|
||||
} from "./modules/websites";
|
||||
|
||||
start();
|
||||
@ -197,6 +208,39 @@ async function crawlProductStock(url: string) {
|
||||
case "silvergear.eu":
|
||||
return [domain, page.url(), await Silvergear.check(html)];
|
||||
|
||||
case "alsa-nature.nl":
|
||||
return [domain, page.url(), await AlsaNature.check(html)];
|
||||
|
||||
case "dobey.nl":
|
||||
return [domain, page.url(), await Dobey.check(html)];
|
||||
|
||||
case "ezydog.nl":
|
||||
return [domain, page.url(), await EzyDog.check(html)];
|
||||
|
||||
case "k9shop.nl":
|
||||
return [domain, page.url(), await K9Shop.check(html)];
|
||||
|
||||
case "onlinehondenspeciaalzaak.nl":
|
||||
return [domain, page.url(), await OnlineHondenSpeciaalZaak.check(html)];
|
||||
|
||||
case "macrovet.nl":
|
||||
return [domain, page.url(), await MacroVet.check(html)];
|
||||
|
||||
case "petduka.nl":
|
||||
return [domain, page.url(), await PetDuka.check(html)];
|
||||
|
||||
case "petsonline.nl":
|
||||
return [domain, page.url(), await PetsOnline.check(html)];
|
||||
|
||||
case "petsplace.nl":
|
||||
return [domain, page.url(), await PetsPlace.check(html)];
|
||||
|
||||
case "zoo-enzo.nl":
|
||||
return [domain, page.url(), await ZooEnzo.check(html)];
|
||||
|
||||
case "thepetempire.com":
|
||||
return [domain, page.url(), await ThePetEmpire.check(html)];
|
||||
|
||||
default:
|
||||
console.error(`-- ${domain} is not an available website module! Can't check stock!`);
|
||||
return [domain, page.url(), false];
|
||||
|
@ -249,4 +249,174 @@ export namespace AlsaNature {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Dobey {
|
||||
export async function check(html: string) {
|
||||
try {
|
||||
const $ = cheerio.load(html);
|
||||
if ($("#product_view #stock_indicator").hasClass("stock_green")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(`Error occured during stock check!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace EzyDog {
|
||||
export async function check(html: string) {
|
||||
try {
|
||||
const $ = cheerio.load(html);
|
||||
if ($(".product-shop .availability").first().hasClass("in-stock")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(`Error occured during stock check!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace K9Shop {
|
||||
export async function check(html: string) {
|
||||
try {
|
||||
const $ = cheerio.load(html);
|
||||
if ($(".ty-qty-in-stock i").first().hasClass("ty-icon-ok")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(`Error occured during stock check!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace OnlineHondenSpeciaalZaak {
|
||||
export async function check(html: string) {
|
||||
try {
|
||||
const $ = cheerio.load(html);
|
||||
if ($("#Product #StockContainer #ShowOutOfStock").hasClass("hidden")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(`Error occured during stock check!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace MacroVet {
|
||||
export async function check(html: string) {
|
||||
try {
|
||||
const $ = cheerio.load(html);
|
||||
if ($(".row-products-blog .row-products-blog2 .active link").attr("href") == "http://schema.org/InStock") {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(`Error occured during stock check!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace PetDuka {
|
||||
export async function check(html: string) {
|
||||
try {
|
||||
const $ = cheerio.load(html);
|
||||
if ($("#product .hurry i").first().hasClass("icon-check-white")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(`Error occured during stock check!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace PetsOnline {
|
||||
export async function check(html: string) {
|
||||
try {
|
||||
const $ = cheerio.load(html);
|
||||
if ($("#content #product_configure_form .overlay-e i").first().hasClass("icon-check-circle")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(`Error occured during stock check!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace PetsPlace {
|
||||
export async function check(html: string) {
|
||||
try {
|
||||
const $ = cheerio.load(html);
|
||||
if ($(".product-info-main #product-addtocart-button").length >= 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(`Error occured during stock check!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace ZooEnzo {
|
||||
export async function check(html: string) {
|
||||
try {
|
||||
const $ = cheerio.load(html);
|
||||
if ($(".row.main_content .availability .available-now link").attr("href") == "http://schema.org/InStock") {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(`Error occured during stock check!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export namespace ThePetEmpire {
|
||||
export async function check(html: string) {
|
||||
try {
|
||||
const $ = cheerio.load(html);
|
||||
if ($("#content .form-product .add-to-cart-button").length >= 1) {
|
||||
return true;
|
||||
} else {
|
||||
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