LET amazon = DOCUMENT('https://www.amazon.com/', true) INPUT(amazon, '#twotabsearchtextbox', @criteria) CLICK(amazon, '.nav-search-submit input[type="submit"]') WAIT_NAVIGATION(amazon) LET resultListSelector = '#s-results-list-atf' LET resultItemSelector = '.s-result-item.celwidget' LET nextBtnSelector = '#pagnNextLink' LET vendorSelector1 = 'div > div:nth-child(3) > div:nth-child(2) > span:nth-child(2)' LET vendorSelector2 = 'div > div:nth-child(5) > div:nth-child(2) > span:nth-child(2)' LET priceWholeSelector = 'span.sx-price-whole' LET priceFracSelector = 'sup.sx-price-fractional' LET pages = TO_INT(INNER_TEXT(amazon, '#pagn > span.pagnDisabled')) LET result = ( FOR pageNum IN 1..pages LET clicked = pageNum == 1 ? false : CLICK(amazon, nextBtnSelector) LET wait = clicked ? WAIT_NAVIGATION(amazon) : false LET waitSelector = wait ? WAIT_ELEMENT(amazon, resultListSelector) : false LET items = ( FOR el IN ELEMENTS(amazon, resultItemSelector) LET priceWholeTxt = INNER_TEXT(el, priceWholeSelector) LET priceFracTxt = INNER_TEXT(el, priceFracSelector) LET price = TO_FLOAT(priceWholeTxt + "." + priceFracTxt) LET vendor = ELEMENT_EXISTS(el, vendorSelector1) ? INNER_TEXT(el, vendorSelector1) : INNER_TEXT(el, vendorSelector2) RETURN { title: INNER_TEXT(el, 'h2'), vendor, price } ) RETURN items ) RETURN FLATTEN(result)