I looked at their APIs and there seem to be a lot of details, but complexity is an obstacle. For long-term use, it would be better to figure this out, but for quick and dirty, here is a way to get the data.
I use Nokogiri , which is an XML / HTML parser and very flexible. For ease of use, I use CSS assemblers.
#!/usr/bin/env ruby require 'open-uri' require 'nokogiri' require 'uri' URL = 'http://en.wikipedia.org/wiki/Ford_Motor_Company' doc = Nokogiri::HTML(open(URL)) infobox = doc.at('table[class="infobox vcard"]') infobox_caption = infobox.at('caption').text uri = URI.parse(URL) infobox_agents = Hash[ *infobox.search('td.agent a').map{ |a| [ a.text, uri.merge(a['href']).to_s ] }.flatten ] require 'ap' ap infobox_caption ap infobox_agents
The result is as follows:
"Ford Motor Company" { "Henry Ford" => "http://en.wikipedia.org/wiki/Henry_Ford", "William C. Ford, Jr." => "http://en.wikipedia.org/wiki/William_Clay_Ford,_Jr.", "Executive Chairman" => "http://en.wikipedia.org/wiki/Chairman", "Alan R. Mulally" => "http://en.wikipedia.org/wiki/Alan_Mulally", "President" => "http://en.wikipedia.org/wiki/President", "CEO" => "http://en.wikipedia.org/wiki/Chief_executive_officer" }
So, he pulled out the text of the inscription and returned a hash of the names of people, where the keys are their names and the values ββare URLs.
source share