Skip to content

Instantly share code, notes, and snippets.

Created Dec 19, 2008
What would you like to do?
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'amazon/aws/search'
require 'erb'
hatena_template = <<-EOT
*** <%= book.item_attributes.title %>
ASIN:<%= book.asin %>:detail
<a href="<%= book.asin %>"></a> での平均評価 [<%= rating %>] (<%= total_reviews %> reviewers)
erb =
doc = Nokogiri::HTML(open(''))
titles = doc.xpath('//li/em').map {|em| em.text }
rg ='Large')
req ='### YOUR AccessKeyId ###')
req.locale = 'us'
titles.each do |title|
is ='Books', {'Title' => title })
res =, rg)
book = res.item_search_response[0].items[0].item[0]
rating = book.customer_reviews.average_rating
total_reviews = book.customer_reviews.total_reviews
puts erb.result(binding)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment