Ruby on Rails 3 and Google Book Search

I'm trying to start using the Google Data API to search for Google books in my Ruby on Rails 3 application, and I don’t even understand how to get started. What gems do I need? What do I need to do to do something simple, for example, look for books called Foobar?

+7
ruby ruby-on-rails ruby-on-rails-3 google-data-api google-books
source share
3 answers

Due to the cancellation issue: I just published GoogleBooks , a Ruby shell that allows users to request books exactly in the way described.

It has been updated to connect to the current Google API, so it has not been affected by the recent condemnation of the Google Book Search API.

+12
source share

If you want to use Google Books to get information about books, you can use their data API: http://code.google.com/apis/books/docs/gdata/developers_guide_protocol.html

Querying a URL, such as http://books.google.com/books/feeds/volumes?q=isbn:9780974514055 , will return the XML with the book information. You can use the Nokogiri stone to analyze the result ( http://nokogiri.org/ ).

One thing you need to know about is that to get full descriptions for books, you need to get a record, not just the feed results.

Here's a quick example of how to get information about a book from Google:

require 'open-uri' require 'nokogiri' class Book attr_accessor :title, :description def self.from_google(title) book = self.new entry = Nokogiri::XML(open "http://books.google.com/books/feeds/volumes?q=#{title}").css("entry id").first xml = Nokogiri::XML(open entry.text) if entry return book unless xml book.title = xml.css("entry dc|title").first.text unless xml.css("entry dc|title").empty? book.description = xml.css("entry dc|description").first.text unless xml.css("entry dc|description").empty? book end end b = Book.from_google("Ruby") pb 
+6
source share

If you want to use api, I think you will have to use jruby and java api. there is no ruby ​​api to search for a book, according to this: http://code.google.com/apis/books/docs/gdata/code.html

to connect to google try using gdata gem. http://code.google.com/apis/gdata/articles/gdata_on_rails.html#SetupRails

0
source share

All Articles