Created
May 23, 2012 09:52
-
-
Save inohiro/2774331 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
FILE = './2008_graph_mining.json' | |
# result of http://www.dblp.org/search/api/?q=ce:year:2008*%20graph*%20mining*&h=1000&c=4&f=0&format=json | |
def scrape | |
file = File.open( FILE ) | |
doc = JSON.parse( file.read ) | |
hits = doc["result"]["hits"]["hit"] | |
hits.each do |hit| | |
title = hit["title"]["dblp:title"]["text"] | |
puts "* #{title}" | |
authors = hit["title"]["dblp:authors"]["dblp:author"] | |
author_base = "** " | |
if authors.class == String | |
author_base << authors | |
elsif authors.class == Array | |
authors.each do |author| | |
author_base << author << ", " | |
end | |
end | |
puts author_base | |
puts "** #{hit["title"]["dblp:venue"]["text"]}" | |
puts '' | |
end | |
file.close | |
end | |
scrape |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment