Skip to content

Instantly share code, notes, and snippets.

@totzyuta
Last active February 15, 2016 02:19
Show Gist options
  • Save totzyuta/4a4ad6d974ccdb224ec6 to your computer and use it in GitHub Desktop.
Save totzyuta/4a4ad6d974ccdb224ec6 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'open-uri'
html = Nokogiri::HTML(File.open(File::expand_path('./source.txt')))
prices = html.css('#kagKinDisp').map {|price| price.content.delete(",").to_i }
times = html.css('#hesKaisuDisp').map(&:content)
result = Array.new
prices.zip(times).each do |price, time|
price / 3 if time == "3"
result << price
end
p result.inject(:+)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment