Fetch an Amazon product's title, price, rating, review count and feature bullets.
{"asin":"string (the 10-char ASIN, e.g. 'B08M94BTYC', or a full amazon.com/dp/ URL)"}{"asin":"string","title":"string","brand":"string|null","price":"string|null","rating":"number|null","reviews":"number|null","availability":"string|null","features":"array of string","url":"url"}Fetch one Amazon product's details from its product page. Navigates to /dp/{asin} and reads the rendered page in the browser. Param: asin (the 10-char ASIN, e.g. 'B08M94BTYC', or a full /dp/ URL from which the extractor derives the ASIN). Returns {asin, title, brand, price, rating, reviews, availability, features, url}. Price is whatever currency Amazon shows for the session's region. Read-only, it never buys.
params. It does the in-page work and returns the JSON in returns.( async (root, params) => { const doc = root && root.querySelector ? root : document; const txt = (el) => el ? (el.innerText || el.textContent || '').trim() : null; let asin = String((params && params.asin) || '').trim(); const m = asin.match(//(?:dp|gp/product)/([A-Z0-9]{10})/i) || asin.match(/^([A-Z0-9]{10})$/i); if (m) asin = m[1]; const title = txt(doc.querySelector('#productTitle')); if (!title) return { asin, error: 'no product title (page not ready or blocked)' }; const price = txt(doc.querySelector('#corePrice_feature_div .a-offscreen, #corePriceDisplay_desktop_feature_div .a-offscreen, #price_inside_buybox, .a-price .a-offscreen')); const ratingRaw = txt(doc.querySelector('#acrPopover .a-icon-alt, #averageCustomerReviews .a-icon-alt')) || ''; const ratingM = ratingRaw.match(/([\d.]+)/); const reviewsRaw = txt(doc.querySelector('#acrCustomerReviewText')) || ''; const reviewsN = reviewsRaw.replace(/[^\d]/g, ''); const brand = txt(doc.querySelector('#bylineInfo')); const availability = txt(doc.querySelector('#availability')); const features = Array.from(doc.querySelectorAll('#feature-bullets li span.a-list-item')).map(txt).filter(Boolean); return { asin, title, brand: brand || null, price: price || null, rating: ratingM ? parseFloat(ratingM[1]) : null, reviews: reviewsN ? parseInt(reviewsN, 10) : null, availability: availability || null, features, url: 'https://www.amazon.com/dp/' + asin }; } )
{
"expr": "typeof result === 'object' && (result.title || result.error)",
"type": "value"
}