diff --git a/amazon.rb b/amazon.rb index 47b9575..2bc04d0 100755 --- a/amazon.rb +++ b/amazon.rb @@ -12,9 +12,7 @@ def get_order_links(agent, page, order_links) links = page.links_with(:text => $overviewtext) - links.each { |link| - order_links.push(link) - } + order_links += links next_link = page.link_with(:text => $nexttext) @@ -60,6 +58,10 @@ def get_order_links(agent, page, order_links) $nexttext = 'Weiter→' end +open('amazon.csv', 'w') { |f| + f.puts "year, amount" +} + a = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' } @@ -154,6 +156,10 @@ def get_order_links(agent, page, order_links) end puts "Done. Year total: " + year_sum.to_s + + open('amazon.csv', 'a') { |f| + f.puts year.text + "," + year_sum.to_s + } end end