Created
September 8, 2014 02:34
-
-
Save colindean/1920b57246ddbe2f7260 to your computer and use it in GitHub Desktop.
List Industry Identifiers from Google Books API
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
#!/usr/bin/env ruby | |
# first arg must be a file in the format | |
# | |
# name identifier | |
# | |
# where name is just something for you and the identifier is an ISBN-10, ISBN-13, | |
# or something else that Google's API understands. | |
require 'json' | |
require 'open-uri' | |
GOOGLE_API_BASE='https://www.googleapis.com/books/v1/volumes?q=%s' | |
input = ARGV[0] | |
puts "Processing #{input}" | |
lines = File.open(input).readlines | |
lines.each do |line| | |
name, isbn13 = line.split | |
puts name | |
puts "isbn13: " + isbn13 | |
data = JSON.parse(open(GOOGLE_API_BASE % isbn13).read) | |
data["items"].each do |item| | |
puts item["volumeInfo"]["industryIdentifiers"] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment