UNPKG

@apify-scrapers/shared

Version:

Shared utilities and constants for Apify scrapers

56 lines (52 loc) 3.67 kB
/** * Platform-specific constants and configurations */ export const PLATFORMS = { SHOPEE: 'shopee', LAZADA: 'lazada', UNKNOWN: 'unknown' }; export const PLATFORM_DOMAINS = { [PLATFORMS.SHOPEE]: ['shopee.sg', 'shopee.com', 'shopee.co.id', 'shopee.com.my', 'shopee.com.ph', 'shopee.co.th', 'shopee.vn'], [PLATFORMS.LAZADA]: ['lazada.sg', 'lazada.com', 'lazada.co.id', 'lazada.com.my', 'lazada.com.ph', 'lazada.co.th', 'lazada.vn'] }; export const PLATFORM_SELECTORS = { [PLATFORMS.SHOPEE]: { productCards: '.shopee-search-item-result__item, [data-sqe="link"], [data-testid="product-card"]', name: ['[data-sqe="name"]', '.ie3A+n', '.Cve6sh', '[data-testid="product-name"]', 'a[title]', '.product-name', '.item-name', '.product-title', '[class*="name"]', 'h3', 'h4'], productUrl: ['a[href*="/product/"]', '[data-sqe="link"]', 'a[href]', '[href*="/item/"]'], image: ['img[src*="down-sg.img.susercontent.com"]', 'img[src*="shopee"]', 'img[data-src]', 'img[src]', '[class*="image"] img', '.product-image img'], price: ['[data-sqe="name"] + div', '.vioxXd', '.price', '.product-price', '[data-testid="price"]', '[class*="price"]', '.current-price', '.sale-price'], originalPrice: ['.price-before', '.original-price', '.strike-through', '.old-price', '[class*="original"]'], rating: ['[data-testid="rating"]', '.rating', '.product-rating', '[class*="rating"]', '.star-rating', '.review-rating'], reviewCount: ['[data-testid="review-count"]', '.review-count', '.product-reviews', '[class*="review"]', '.review-count', '.product-reviews'], soldCount: ['[data-testid="sold-count"]', '.sold-count', '.product-sold', '[class*="sold"]', '.sold-count', '.product-sold'], seller: ['[data-testid="seller"]', '.seller', '.shop-name', '[class*="seller"]', '.shop-name'], location: ['[data-testid="location"]', '.location', '.product-location', '[class*="location"]', '.product-location'], discount: ['.discount', '.sale-badge', '.promotion', '[class*="discount"]', '.sale-badge', '.promotion'] }, [PLATFORMS.LAZADA]: { productCards: '[data-qa-locator="product-item"], .Bm3ON, [data-tracking="product-card"]', name: ['.RfADt a', '.product-name', 'a[title]', '[class*="title"]', 'h3', 'h4', '.product-title'], productUrl: ['a[href*="/products/"]', 'a[href*="/pdp-"]', 'a[href]'], image: ['img[type="product"]', 'img[alt*="product"]', 'img[src]', '.picture-wrapper img'], price: ['.ooOxS', '.price', '.product-price', '[class*="price"]', '.current-price', '.sale-price'], originalPrice: ['.price-before', '.original-price', '.strike-through', '.old-price', '[class*="original"]'], rating: ['.mdmmT', '.rating', '.product-rating', '[class*="rating"]', '.star-rating', '.review-rating'], reviewCount: ['.qzqFw', '.review-count', '.product-reviews', '[class*="review"]', '.review-count', '.product-reviews'], soldCount: ['._1cEkb span', '.sold-count', '.product-sold', '[class*="sold"]', '.sold-count', '.product-sold'], seller: ['.seller', '.shop-name', '[class*="seller"]', '.shop-name'], location: ['.oa6ri', '.location', '.product-location', '[class*="location"]', '.product-location'], discount: ['.ic-dynamic-badge', '.discount', '.sale-badge', '.promotion', '[class*="discount"]', '.sale-badge', '.promotion'] } }; export const DEFAULT_CONFIG = { maxPages: 3, maxItems: 10, requestDelay: 2000, maxConcurrency: 2, maxRequestRetries: 3, requestHandlerTimeoutSecs: 60, navigationTimeoutSecs: 120, pageLoadTimeoutSecs: 90 };