Hello,
I've put together a factbook gem [1] that lets you read in World
Factbook country profile pages (in HTML) and returns a structured Ruby
hash that you can save, for example, as a pretty printed JSON file.
Example:
Get country profile page for Brazil (br) as a hash (that is,
structured data e.g. nested key/values)
page = Factbook::Page.new( 'br' )
pp page.data # pretty print hash
Save to disk as JSON
File.open( 'br.json', 'w') do |f|
f.write page.to_json( pretty: true )
end
and so on.
Find ready-to-use country profile in JSON in the
openmundi/factbook.json [2] repo.
Thanks to the CIA for the great service (and public domain data - no
rights reserved, no copyright).
Cheers.
[1] github.com/worlddb/factbook.ruby
[2] github.com/openmundi/factbook.json
Very nice! Thanks for this gem..
saji
Saji N Hameed,
ARC-ENV, Center for Advanced Information Science and Technology,
University of Aizu, Tsuruga, Ikki-machi,
Aizuwakamatsu-shi, Fukushima 965-8580,
Japan
Tel: +81242 37-2736
Fax:+81242 37-2760
email: saji@u-aizu.ac.jp
url: http://enformtk.u-aizu.ac.jp
bib: Web of Science
code: sajinh (Saji Hameed) · GitHub
···
On Sat, Jul 12, 2014 at 10:47 PM, Gerald Bauer <gerald.bauer@gmail.com> wrote:
Hello,
I've put together a factbook gem [1] that lets you read in World
Factbook country profile pages (in HTML) and returns a structured Ruby
hash that you can save, for example, as a pretty printed JSON file.
Example:
Get country profile page for Brazil (br) as a hash (that is,
structured data e.g. nested key/values)
page = Factbook::Page.new( 'br' )
pp page.data # pretty print hash
Save to disk as JSON
File.open( 'br.json', 'w') do |f|
f.write page.to_json( pretty: true )
end
and so on.
Find ready-to-use country profile in JSON in the
openmundi/factbook.json [2] repo.
Thanks to the CIA for the great service (and public domain data - no
rights reserved, no copyright).
Cheers.
[1] github.com/worlddb/factbook.ruby
[2] github.com/openmundi/factbook.json