I started dabbling in Ruby some weeks back. The initial interest was sparked after reading "Treating Code as an Essay" (Yukihiro Matsumoto) - one of the chapters in Beautiful Code. So I started doing these bootstrapping exercises in Ruby. Some of the exercises are good - but nothing beats doing a small project to learn a new language.

I buy a lot of books, mostly online. There are a few good online bookstores in India, notably Flipkart.com, Infibeam.com and Indiaplaza.in (Sadly, Amazon does not have full-fledged shipping to India yet). The way I usually search for a book in online bookstores is (was, till now)

  1. Go to books.google.com and enter the book title
  2. Click on the best match
  3. Click on 'All Sellers' on the left of the page
  4. The Indian bookstores are usually listed towards the bottom. It does not include all stores, and sometimes the prices are not listed. I have to go to each individual site and check them out.

I wanted to collapse these steps into one - a simple script that would accept the name of the book and show results from all these bookstores, with comparative pricing. And the result was this

http://github.com/talonx/book-search

It's in Ruby, runs from the command line and writes the output to an HTML in the same directory called 'search.html'. Much needs to be done, like

  • Price based listing with the lowest on top
  • A web interface for the search
  • Add more bookstores - it's only Flipkart.com, Infibeam.com, Indiaplaza and Bookadda.com right now.

To run the script, type this (you need Ruby 1.8.x, available from http://www.ruby-lang.org/en/downloads/ and the Hpricot HTML parser library, available from http://github.com/whymirror/hpricot)
ruby lib\book-search.rb "<book title (in quotes if it has spaces)>"