Permalink
Browse files

Work around disambiguation pages like "Free association"

  • Loading branch information...
1 parent 1940fb5 commit 860d3f401fbdd34aeb2d5b0d5bf79a21149030ef @drbrain drbrain committed Jan 24, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 examples/wikipedia_links_to_philosophy.rb
View
6 examples/wikipedia_links_to_philosophy.rb
@@ -74,6 +74,12 @@ def follow_first_link
link = links.first
+ unless link then
+ # disambiguation page? try the first item in the list
+ link =
+ @page.root.css('.mw-content-ltr > ul > li > a[href^="/wiki/"]').first
+ end
+
# convert a Nokogiri HTML element back to a mechanize link
link = Mechanize::Page::Link.new link, @agent, @page

0 comments on commit 860d3f4

Please sign in to comment.