Created
February 29, 2012 09:33
-
-
Save hirocaster/1939444 to your computer and use it in GitHub Desktop.
amazon.co.jp stock check script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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