Created
September 9, 2016 21:49
-
-
Save AumCoin/1f32b9826c03402a58bae7cef650be06 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def rip_prices ### This takes about 3 minutes | |
products = {} | |
currencies = ["EUR","USD"]#,"GBP","AUD","CAD","CZK","DKK","MXN","NOK","SEK","TRY"] | |
currencies.each do |currency| | |
unless File.exist?("google_" + currency + "_english_1.xml") | |
puts "File google_" + currency + "_english_1.xml does not exist. Skipping..." | |
next | |
end | |
puts "processing " + currency + " file." | |
doc = XmlSimple.xml_in (File.open("google_" + currency + "_english_1.xml", "r").read); nil | |
i = 0 | |
doc["channel"][0]["item"].each do |item| | |
itemno = item["id"][0] | |
price = item["price"][0].split[0] | |
products[itemno] ||= {} | |
products[itemno]["prices"] = {} | |
products[itemno]["prices"][currency] = price | |
i += 1 | |
end | |
end | |
puts products | |
Dir.chdir "C:\\MyScripts\\DB\\Data" | |
YAML.dump(products, File.open("kinguin_prices_hash.yml", 'w')) | |
sleep 1 | |
end | |
RAW Paste Data | |
AdClubhouse: Project management software you'll actually enjoy using. | |
def rip_prices ### This takes about 3 minutes | |
products = {} | |
currencies = ["EUR","USD"]#,"GBP","AUD","CAD","CZK","DKK","MXN","NOK","SEK","TRY"] | |
currencies.each do |currency| | |
unless File.exist?("google_" + currency + "_english_1.xml") | |
puts "File google_" + currency + "_english_1.xml does not exist. Skipping..." | |
next | |
end | |
puts "processing " + currency + " file." | |
doc = XmlSimple.xml_in (File.open("google_" + currency + "_english_1.xml", "r").read); nil | |
i = 0 | |
doc["channel"][0]["item"].each do |item| | |
itemno = item["id"][0] | |
price = item["price"][0].split[0] | |
products[itemno] ||= {} | |
products[itemno]["prices"] = {} | |
products[itemno]["prices"][currency] = price | |
i += 1 | |
end | |
end | |
puts products | |
Dir.chdir "C:\\MyScripts\\DB\\Data" | |
YAML.dump(products, File.open("kinguin_prices_hash.yml", 'w')) | |
sleep 1 | |
end |
baweaver
commented
Sep 9, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment