Skip to content

Instantly share code, notes, and snippets.

@satetsu888
Created June 2, 2015 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satetsu888/c4fd47b0d69c10203d9e to your computer and use it in GitHub Desktop.
Save satetsu888/c4fd47b0d69c10203d9e to your computer and use it in GitHub Desktop.
amatenの価格調べ
require 'nokogiri'
require 'open-uri'
base_url = 'https://amaten.jp/exhibitions/past_gifts?page=%s&type=amazon'
last_line = 0;
current_line = 0;
page = 1;
loop do
url = sprintf(base_url, page)
charset = nil
html = open(url) do |f|
charset = f.charset
f.read
end
doc = Nokogiri::HTML.parse(html, nil, charset)
table = doc.css('table#gift_list')
table.css('tr.odd').each{|line|
datatime = line.css('td.cellLimit')
price = line.css('td.cellPrice')
rate = line.css('td.cellRate')
print datatime.text + ", " + rate.text + "\n"
current_line+=1
}
page+=1
if current_line == last_line then
break
else
last_line = current_line
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment