public
Description: A handful (but hopefully growing amount) of scRUBYt! examples
Homepage: http://scrubyt.org
Clone URL: git://github.com/scrubber/scrubyt_examples.git
scrubyt_examples / google_analytics.rb
100644 20 lines (15 sloc) 0.549 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# google analytics scraper
#
# not trivial (besides the usual AJAX things) as the login form is in a frame
# as usual, replace asterisks with your username / pass
 
require 'rubygems'
require 'scrubyt'
 
data = Scrubyt::Extractor.define :agent => :firefox do
  fetch 'https://www.google.com/analytics/reporting/login'
  frame :name, "login"
  
  fill_textfield 'Email', '*****'
  fill_textfield 'Passwd', '*****'
  submit_and_wait 5
  
  pageviews "//div[@id='PageviewsSummary']//li[@class='item_value']", :example_type => :xpath
end
 
puts data.to_xml