Created
July 5, 2010 17:51
-
-
Save tinogomes/464544 to your computer and use it in GitHub Desktop.
lista de cartas disponíveis e script para pegar os preços no Universo Parelelo
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
1,Grixis Panorama,Land | |
1,Naya Panorama,Land | |
1,Bant Panorama,Land | |
1,Obelisk of Esper,3 | |
1,Obelisk of Bant,3 | |
1,Lush Growth,G | |
1,Elvish Visionary,1G | |
1,Elvish Visionary,1G | |
1,Cylian Elf,1G | |
1,Savage Hunger,2G | |
1,Savage Hunger,2G | |
1,Rhox Charger,3G | |
1,Drumhunter,3G | |
1,Souls Might,4G | |
1,Gustrider Exuberant,2W | |
1,Guardians of Akrasa,2W | |
1,Welkin Guide,4W | |
1,Rockcaster Platoon,5WW | |
1,Yoked Plowbeast,5WW | |
1,Sphinxs Herald,U | |
1,Cancel,1UU | |
1,Spell Snip,2U | |
1,Etherium Astrolabe,2U | |
1,Outrider of Jhess,3U | |
1,Fatestitcher,3U | |
1,Tidehollow Sculler,WB | |
1,Tidehollow Strix,UB | |
1,Branching Bolt,1RG | |
1,Sedraxis Specter,UBR | |
1,Kederekt Creeper,UBR | |
1,Kederekt Creeper,UBR | |
1,Rakeclaw Gargantuan,2RGW | |
1,Rakeclaw Gargantuan,2RGW | |
1,Sangrite Surge,4RG | |
1,Bull Cerodon,4RW | |
6,Plain,Basic Land | |
6,Florest,Basic Land |
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
%w(rubygems csv nokogiri open-uri).each do |req| | |
require req | |
end | |
def get_price_for_card(card_name) | |
uponline_base_url = "http://uponline.com.br/pesquisa.php?setor=Cartas&key=" | |
doc = Nokogiri::HTML(open("#{uponline_base_url}#{card_name.split.join('+')}")) | |
begin | |
result = doc.css("table#lista_completa tr.bg_tr_off td[3]") | |
return "verify, more than 1 price" if result.size > 1 | |
result.first.content | |
rescue | |
"'#{card_name}' is not a valid card name." | |
end | |
end | |
def convert_to_number(value) | |
v = value.gsub("R$ 0,", "") | |
v.gsub!("R$ ", "") | |
v.gsub!(",", "") | |
v.to_i | |
end | |
cards = CSV.open('magic-cards.txt', 'r') | |
total = 0 | |
cards.each do |card| | |
value = get_price_for_card(card[1]) | |
total += convert_to_number(value) | |
card << value.to_s | |
p card | |
end | |
p "Total = #{total/100.0}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment