Pages

Saturday, 26 December 2009

A Ruby script to search bookstores online

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)

Go to books.google.com and enter the book title

Click on the best match

Click on 'All Sellers' on the left of the page

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

@Surya: Yes. Also, a lot of the Indian editions of technical books that you can buy here cost much less than the original editions :). I also found this - http://www.amazonglobal.com/ - where you can search for items that ship internationally.

I have been thinking of having something which would search all online stores for a particular item ..by product name or code and bring to me the price, any offers on that product and other details like shipping rates, time etc.. Is this possible?I need to learn ruby or anything which will help me achieve this...

@Shri: The script I wrote visits each website and "scrapes" (i.e., fetches and parses) the HTML and shows the results. So what you mention is definitely possible. You'll have to analyze the structure of the search results page of each online store you wish to include in your results.