AmazonCouponScraper - itsManeka/amazing-scraper GitHub Wiki
amazing-scraper / AmazonCouponScraper
Defined in: src/index.ts:90
Public scraper interface returned by createScraper.
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).
string
Promise<ApplicableCouponResult>
if (page.individualCouponInfo?.isApplicable) {
const result = await scraper.extractApplicableCouponProducts(
page.individualCouponInfo,
page.asin,
);
console.log(result.asins, result.expiresAt);
}extractCouponProducts(
couponInfo):Promise<CouponResult>
Defined in: src/index.ts:100
Extracts all products participating in a coupon promotion.
Requires CouponInfo previously obtained from fetchProduct.
Promise<CouponResult>
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.
string
Promise<string | null>
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.
Promise<FetchPreSalesResult>
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.
string
Promise<ProductPage>