Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #10 from afnecors/extlinks

add extlinks method
  • Loading branch information...
commit c55378a907d52de08fba15893961ddcafca594fb 2 parents a9b5c0c + 8b978d1
Ken Pratt authored
5 README.textile
View
@@ -34,6 +34,10 @@ page.links
=> [..., "Business", "Cult following", ...]
+page.extlinks
+
+=> [..., "http://www.example.com/", ...]
+
page.images
=> ["File:Getting Things Done.jpg", ...]
@@ -43,6 +47,7 @@ page.image_urls
=> ["http://upload.wikimedia.org/wikipedia/en/e/e1/Getting_Things_Done.jpg"]
page.image_descriptionurls
+
=> ["http://en.wikipedia.org/wiki/File:Getting_Things_Done.jpg"]
page.coordinates
4 lib/wikipedia/client.rb
View
@@ -13,7 +13,7 @@ def find( title, options = {} )
title = Url.new(title).title rescue title
page = Page.new( request_page( title, options ) )
while follow_redirects and page.redirect?
- page = Page.new( request_page( page.redirect_title, options ))
+ page = Page.new( request_page( page.redirect_title, options ) )
end
page
end
@@ -27,7 +27,7 @@ def find_image( title, options = {} )
def request_page( title, options = {} )
request( {
:action => "query",
- :prop => %w{ revisions links images categories coordinates templates },
+ :prop => %w{ revisions links extlinks images categories coordinates templates },
:rvprop => "content",
:titles => title
}.merge( options ) )
4 lib/wikipedia/page.rb
View
@@ -40,6 +40,10 @@ def links
page['links'].map {|c| c['title'] } if page['links']
end
+ def extlinks
+ page['extlinks'].map {|c| c['*'] } if page['extlinks']
+ end
+
def images
page['images'].map {|c| c['title'] } if page['images']
end
Please sign in to comment.
Something went wrong with that request. Please try again.