Skip to content

Instantly share code, notes, and snippets.

@hirocaster
Created February 29, 2012 09:33
Show Gist options
  • Save hirocaster/1939444 to your computer and use it in GitHub Desktop.
Save hirocaster/1939444 to your computer and use it in GitHub Desktop.
amazon.co.jp stock check script
# -*- coding: utf-8 -*-
require 'nokogiri'
require 'open-uri'
require 'kconv'
page = open "http://www.amazon.co.jp/exec/obidos/ASIN/4048860690/"
# page = open "http://www.amazon.co.jp/exec/obidos/ASIN/4774149942/"
html = Nokogiri::HTML(page.read, nil, 'Shift_JIS')
stock = html.search "//div[@class='buying']//span[@class='availGreen']"
if stock.inner_html.toutf8 == "在庫あり。"
puts 'この商品の在庫はあります。'
else
puts '売りきれ'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment