Created
February 1, 2012 23:24
-
-
Save pwaldhauer/1720125 to your computer and use it in GitHub Desktop.
Amazon Bestellungen Grabber
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
require 'rubygems' | |
require 'mechanize' | |
a = Mechanize.new { |agent| | |
agent.user_agent_alias = 'Mac Safari' | |
} | |
a.get('http://amazon.de/') do |page| | |
login_page = a.click(page.link_with(:text => 'Melden Sie sich an')) | |
logged_in_page = login_page.form_with(:id => 'ap_signin_form') do |f| | |
f.email = 'BLAH BLAH LAHBa' | |
f.password = 'SUPERGEHEIM' | |
end.click_button | |
account_page = a.click(logged_in_page.link_with(:text => 'Mein Konto')) | |
orders_page = a.click(account_page.link_with(:text => 'Bestellungen')) | |
years = Array.new | |
select_form = orders_page.form_with(:id => 'order-dropdown-form') | |
select_form.field_with(:name => 'orderFilter').options.each do |option| | |
if( option.value == 'select-another' or option.value == 'last30' or option.value == 'months-6') then | |
next | |
end | |
option.select | |
year_page = select_form.submit | |
count = year_page.search(".//div[@class='num-results']/b[1]") | |
year = year_page.search(".//div[@class='num-results']/b[2]") | |
puts "Jahr " + year.text + ", " + count.text + " Bestellungen" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment