Skip to content

Instantly share code, notes, and snippets.

@tadelv
Created January 11, 2011 14:30
Show Gist options
  • Save tadelv/774469 to your computer and use it in GitHub Desktop.
Save tadelv/774469 to your computer and use it in GitHub Desktop.
plz don't kill me, i don't know how to write code
require 'rubygems'
require 'open-uri'
require "hpricot"
html = open('http://www.amzs.si/?podrocje=18').read
doc = Hpricot(html)
count_ary = (doc/"td.DefaultTemplate/table/tr").to_ary
countries = count_ary[3..41]
#use without first, to get all countries
#country = (doc/"td.DefaultTemplate/table/tr[4]").first
countries.each do |country|
country_name = (country/"td[1]").inner_html
gas95 = (country/"td[3]").inner_html
gas98 = (country/"td[4]").inner_html
diesel = (country/"td[5]").inner_html
puts "#{country_name.encode("utf-8")} :: #{gas95} :: #{gas98} :: #{diesel}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment