开发者

Paginate the results from Amazon product search

开发者 https://www.devze.com 2023-04-01 20:56 出处:网络
I am using the gem amazon_product for searching the books in Amazon. The search is perfectly fine but it gets me only a list of first 10 books.

I am using the gem amazon_product for searching the books in Amazon. The search is perfectly fine but it gets me only a list of first 10 books. I want to get all the search results and paginate them. How can I do this?

开发者_如何学Go

My code looks like this,

req = AmazonProduct["us"]
req.configure do |c|
  c.key    = "KEY"
  c.secret = "SECRET_KEY"
  c.tag    = "TAG" 
end
resp = req.search("Books", :power => params[:book][:search_term], :sort => "reviewrank")
@books = resp.to_hash["Items"]["Item"]


From their API page at - http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl

They have "RelatedItemPage" and "ItemPage"

You should give this a try

resp = req.search("Books", :power => params[:book][:search_term], :itemPage => 20)

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消