AmazonCouponScraper - itsManeka/amazing-scraper GitHub Wiki

amazing-scraper


amazing-scraper / AmazonCouponScraper

Interface: AmazonCouponScraper

Defined in: src/index.ts:90

Public scraper interface returned by createScraper.

Methods

extractApplicableCouponProducts()

extractApplicableCouponProducts(couponInfo, sourceAsin): Promise<ApplicableCouponResult>

Defined in: src/index.ts:139

Extracts products participating in an applicable coupon (pattern: "Aplicar cupom de X%"). Requires IndividualCouponInfo with isApplicable === true previously obtained from fetchProduct.

Two flows:

  • Coupon-03 (no participating products page): returns { asins: [sourceAsin], expiresAt } only.
  • Coupon-04 (with participating products page): fetches the page, paginates through products, and returns all participating ASINs or falls back to [sourceAsin] if none found.

Always extracts expiration date from coupon terms (via fetchIndividualCouponTerms).

Parameters

couponInfo

IndividualCouponInfo

sourceAsin

string

Returns

Promise<ApplicableCouponResult>

Example

if (page.individualCouponInfo?.isApplicable) {
  const result = await scraper.extractApplicableCouponProducts(
    page.individualCouponInfo,
    page.asin,
  );
  console.log(result.asins, result.expiresAt);
}

extractCouponProducts()

extractCouponProducts(couponInfo): Promise<CouponResult>

Defined in: src/index.ts:100

Extracts all products participating in a coupon promotion. Requires CouponInfo previously obtained from fetchProduct.

Parameters

couponInfo

CouponInfo

Returns

Promise<CouponResult>


fetchIndividualCouponTerms()

fetchIndividualCouponTerms(termsUrl): Promise<string | null>

Defined in: src/index.ts:116

Fetches the terms text of an "individual" coupon from the Amazon popover endpoint (/promotion/details/popup/{PROMOTION_ID}).

Accepts the relative or absolute URL exposed by IndividualCouponInfo.termsUrl. The resolved hostname is pinned to www.amazon.com.br to mitigate SSRF. Returns null on network failure, non-200 response, foreign-host URL, or when the terms selector is absent.

Parameters

termsUrl

string

Returns

Promise<string | null>


fetchPreSales()

fetchPreSales(options?): Promise<FetchPreSalesResult>

Defined in: src/index.ts:105

Fetches pre-sale ASINs from the Amazon HQ & Manga search page. Paginates and stops based on page limit or stop-ASIN sentinel.

Parameters

options?

FetchPreSalesOptions

Returns

Promise<FetchPreSalesResult>


fetchProduct()

fetchProduct(asin): Promise<ProductPage>

Defined in: src/index.ts:95

Fetches a single product page and returns its structured data. Does not follow coupon links or paginate.

Parameters

asin

string

Returns

Promise<ProductPage>

⚠️ **GitHub.com Fallback** ⚠️