Search Amazon products by keyword, returning title, price, rating and reviews.
{"query":"string (search text)"}{"count":"int","query":"string","results":"array of { asin, title, url, price, rating, reviews, image, sponsored }"}Search Amazon products by keyword. Navigates the search results page and reads the rendered product cards in the browser (Amazon's search API is gated by rotating tokens and bot detection, so the page DOM is the reliable source). Param: query (search text). Returns {count, results:[{asin, title, url, price, rating, reviews, image, sponsored}]}. Price is whatever currency Amazon shows for the session's region. Read-only, it never adds to cart.
params. It does the in-page work and returns the JSON in returns.( async (root, params) => { const doc = root && root.querySelectorAll ? root : document; const txt = (el) => el ? (el.innerText || el.textContent || '').trim() : null; const cards = Array.from(doc.querySelectorAll('div[data-component-type="s-search-result"]')); const results = cards.map((c) => { const asin = c.getAttribute('data-asin') || null; if (!asin) return null; const titleEl = c.querySelector('h2 a span, h2 span, h2'); const linkEl = c.querySelector('a.a-link-normal[href*="/dp/"], h2 a'); let href = linkEl ? linkEl.getAttribute('href') : null; if (href && href[0] === '/') href = 'https://www.amazon.com' + href.split('?')[0]; const price = txt(c.querySelector('.a-price .a-offscreen')); const ratingRaw = (c.querySelector('.a-icon-alt') || {}).textContent || ''; const ratingM = ratingRaw.match(/([\d.]+)/); const rating = ratingM ? parseFloat(ratingM[1]) : null; let reviews = null; const rc = c.querySelector('a[href*="#customerReviews"] span, [aria-label$="ratings"], [data-csa-c-content-id="alf-customer-ratings-count-component"] span, .a-size-base.s-underline-text'); if (rc) { const n = (txt(rc) || '').replace(/[^\d]/g, ''); if (n) reviews = parseInt(n, 10); } const img = c.querySelector('img.s-image'); const image = img ? img.getAttribute('src') : null; const sponsored = !!c.querySelector('[aria-label="View Sponsored information"], .puis-sponsored-label-text, .s-sponsored-label-text'); return { asin, title: txt(titleEl), url: 'https://www.amazon.com/dp/' + asin, price: price || null, rating, reviews, image, sponsored }; }).filter((r) => r && r.title); return { count: results.length, query: String((params && params.query) || ''), results }; } )
{
"expr": "typeof result === 'object' && Array.isArray(result.results)",
"type": "value"
}