universal-pdp-scrapper
Version:
A universal pdp scrapper using cheerio & ChatGPT
102 lines (101 loc) • 2.4 kB
TypeScript
import type { ScrapperOutput } from '../types/scrapperOutput';
export interface IkeaProduct {
catalogRefs?: CatalogRefs;
currencyCode?: string;
experimental?: Experimental;
globalId?: string;
id?: string;
mainImage?: Image;
name?: string;
pipUrl?: string;
price?: string;
priceExclTax?: string;
priceExclTaxNumeral?: number;
priceNumeral?: number;
revampPrice?: RevampPrice;
styleGroup?: string;
typeName?: string;
validDesignText?: string;
}
export interface CatalogRefs {
products: Products;
themes: Products;
}
export interface Products {
elements?: Products[];
id: string;
name: string;
url: string;
}
export interface Experimental {
contextualImage: Image;
isBreathTakingItem: boolean;
isFamilyPrice: boolean;
isNewLowerPrice: boolean;
isNewProduct: boolean;
isTimeRestricted: boolean;
priceUnit: string;
rating: Rating;
technicalCompliance: TechnicalCompliance;
}
export interface Image {
alt: string;
id: string;
imageFileName: string;
type: string;
url: string;
}
export interface Rating {
count: number;
enabled: boolean;
maxValue: number;
percentage: number;
value: number;
}
export interface TechnicalCompliance {
valid: boolean;
}
export interface RevampPrice {
currencyPrefix: string;
currencySuffix: string;
currencySuffixZeroDecimals: boolean;
currencySymbol: string;
decimals: string;
hasTrailingCurrency: boolean;
integer: string;
numDecimals: number;
separator: string;
}
export interface IkeaModel {
models: Model[];
itemType: string;
categorization: Categorization;
variations: Variation[];
}
export interface Categorization {
hfbName: string;
hfbId: string;
rangeName: string;
rangeId: string;
areaName: string;
areaId: string;
}
export interface Model {
markets: string[];
url: string;
geoEnabled: boolean;
}
export interface Variation {
localId: string;
itemType: string;
models: Model[];
}
export declare class Ikea {
static readonly BASE_URL = "https://www.ikea.com";
readonly url: string;
readonly sku: string;
constructor(url: string);
getProductDetails(): Promise<IkeaProduct | null>;
getGLBs(): Promise<IkeaModel | null>;
extract(html?: string): Promise<ScrapperOutput>;
}