Module: StumbleUpon
- Defined in:
- lib/stumbleupon.rb
Defined Under Namespace
Classes: Favourites
Class Method Summary collapse
Class Method Details
.fetch_page(user, page_number = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/stumbleupon.rb', line 38 def self.fetch_page(user, page_number=nil) url = "http://www.stumbleupon.com/stumbler/#{user}/favorites/" if page_number && (page_number > 0) url += (page_number * 10).to_s url += "/" end mechanize = WWW::Mechanize.new{|agent| agent.user_agent_alias = "Linux Mozilla"} list_view = mechanize.get(url).search("a").select{|x| x["href"] =~ /viewmode=list/}[0] mechanize.click(list_view) if list_view mechanize.page.search("dl.dlBlog").map{|post| parse_review(post)}.compact end |