lib/onebox/engine/amazon_onebox.rb in onebox-1.5.27 vs lib/onebox/engine/amazon_onebox.rb in onebox-1.5.28

- old
+ new

@@ -43,14 +43,20 @@ end def data result = { link: link, title: raw.css("title").inner_text, - image: image, - price: raw.css("#priceblock_ourprice").inner_text } + image: image } result[:by_info] = raw.at("#by-line") result[:by_info] = Onebox::Helpers.clean(result[:by_info].inner_html) if result[:by_info] + + # get item price (Amazon markup is inconsistent, deal with it) + if raw.css("#priceblock_ourprice .restOfPrice")[0] && raw.css("#priceblock_ourprice .restOfPrice")[0].inner_text + result[:price] = "#{raw.css("#priceblock_ourprice .restOfPrice")[0].inner_text}#{raw.css("#priceblock_ourprice .buyingPrice")[0].inner_text}.#{raw.css("#priceblock_ourprice .restOfPrice")[1].inner_text}" + else + result[:price] = raw.css("#priceblock_ourprice").inner_text + end summary = raw.at("#productDescription") result[:description] = summary.inner_text if summary result end