diff -urN mingplot-0.3/amazonplot.rb mingplot-0.3.new/amazonplot.rb --- mingplot-0.3/amazonplot.rb 2004-03-23 16:59:55.000000000 +0900 +++ mingplot-0.3.new/amazonplot.rb 2008-04-11 01:49:32.000000000 +0900 @@ -41,14 +41,14 @@ def get_xml_host_name (locale) xml_host_table = { - "jp" => "xml.amazon.co.jp", - "fr" => "xml-eu.amazon.com", - "de" => "xml-eu.amazon.com", - "uk" => "xml-eu.amazon.com", - "ca" => "xml.amazon.com", - "us" => "xml.amazon.com", + "jp" => "ecs.amazonaws.jp", + "fr" => "ecs.amazonaws.fr", + "de" => "ecs.amazonaws.de", + "uk" => "ecs.amazonaws.co.uk", + "ca" => "ecs.amazonaws.ca", + "us" => "ecs.amazonaws.com", } - (xml_host_table[locale] or "xml.amazon.com") + (xml_host_table[locale] or "ecs.amazonaws.com") end end @@ -201,32 +201,32 @@ response = nil Net::HTTP.start(@service_host, 80) {|http| query = CGI.escape(key) - format = "/onca/xml3?t=%s&dev-t=%s&AsinSearch=%s&type=%s&f=%s&locale=%s" - path = sprintf(format, - "webservices-20", @token, query, "heavy", "xml", @locale) + format = "/onca/xml?Service=AWSECommerceService&SubscriptionId=%s&AssociateTag=%s&Operation=ItemLookup&ItemId=%s&ResponseGroup=%s&Version=%s" + path = sprintf(format, + @token, @id, query, "Medium,OfferFull,Reviews", "2007-07-16") response = http.get2(path) } REXML::Document.new(response.body) end def collect_info (doc) - prefix = "/ProductInfo/Details/" + prefix = "/ItemLookupResponse/Items/Item/" info = Hash.new - info[:asin] = get_string(doc, prefix + "Asin") + info[:asin] = get_string(doc, prefix + "ASIN") info[:rank] = get_number(doc, prefix + "SalesRank") - info[:price] = get_number(doc, prefix + "OurPrice") - info[:used_price] = get_number(doc, prefix + "UsedPrice") - info[:third_party_price] = get_number(doc, prefix + "ThirdPartyNewPrice") - info[:release_date] = get_string(doc, prefix + "ReleaseDate") - info[:rating] = get_number(doc, prefix + "Reviews/AvgCustomerRating") - info[:nreviews] = get_number(doc, prefix + "Reviews/TotalCustomerReviews") - info[:title] = get_string(doc, "/ProductInfo/Details/ProductName") - info[:author] = get_string(doc, prefix + "Authors/Author", true) - info[:artist] = get_string(doc, prefix + "Artists/Artist", true) - info[:manufacturer] = get_string(doc, prefix + "Manufacturer") - info[:catalog] = get_string(doc, prefix + "Catalog") - info[:image_url] = get_string(doc, prefix + "ImageUrlMedium") - info[:features] = get_string(doc, prefix + "Features/Feature", true) + info[:price] = get_number(doc, prefix + "Offers/Offer[Merchant/Name/text()='Amazon.co.jp']/OfferListing/Price/Amount") + info[:used_price] = get_number(doc, prefix + "OfferSummary/LowestUsedPrice/Amount") + info[:third_party_price] = get_number(doc, prefix + "Offers/Offer[(Seller/Nickname or Merchant/Name/text() != 'Amazon.co.jp')]") + info[:release_date] = get_string(doc, prefix + "ItemAttributes/PublicationDate") || get_string(doc, prefix + "ItemAttributes/ReleaseDate") + info[:rating] = get_number(doc, prefix + "CustomerReviews/AverageRating") + info[:nreviews] = get_number(doc, prefix + "CustomerReviews/TotalReviews") + info[:title] = get_string(doc, prefix + "ItemAttributes/Title") + info[:author] = get_string(doc, prefix + "ItemAttributes/Author", true) + info[:artist] = get_string(doc, prefix + "ItemAttributes/Artist", true) + info[:manufacturer] = get_string(doc, prefix + "ItemAttributes/Manufacturer") + info[:catalog] = get_string(doc, prefix + "ItemAttributes/ProductGroup") + info[:image_url] = get_string(doc, prefix + "MediumImage/URL") + info[:features] = get_string(doc, prefix + "ItemAttributes/Feature", true) info[:locale] = @locale info[:associate_id] = @id return info @@ -236,7 +236,7 @@ def search (key) doc = search_amazon(key) - if get_string(doc, "ProductInfo/ErrorMsg") # error occurred + if get_string(doc, "/ItemLookupResponse/Items/Request/Errors/Error/Message") return nil else info = collect_info(doc)