Skip to content

Instantly share code, notes, and snippets.

@inohiro
Created May 23, 2012 09:52
Show Gist options
  • Save inohiro/2774331 to your computer and use it in GitHub Desktop.
Save inohiro/2774331 to your computer and use it in GitHub Desktop.
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