Permalink
Browse files

Updating search link, thanks to email from Indiaplaza books marketing…

… manager
  • Loading branch information...
1 parent 425b515 commit c40d7d2f20db1bbf3f700872bb94b2494f3078e6 @swaroopch committed Nov 7, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 app/models/bookprice.rb
View
@@ -32,6 +32,7 @@ def number_of_stores
class << self
def find_price_at_end(text)
+ return NOT_AVAILABLE if text.blank?
text.strip!
price = /[,\d]+(\.\d+)?$/.match(text).to_s.gsub(",","").to_f
price > 0 ? price : NOT_AVAILABLE
@@ -122,10 +123,14 @@ def search_rediff(isbn)
end
def search_indiaplaza(isbn)
- url = "http://www.indiaplaza.in/search.aspx?catname=Books&srchkey=sku&srchVal=#{isbn}"
+ url = "http://www.indiaplaza.com/books/#{isbn}.htm"
page = self.fetch_page(url)
unless page.nil?
- text = page.search("div.tier1box2/ul/li:first-child").text
+ begin
+ text = page.search("div#content li:first-child")[0].children[1].text
+ rescue
+ text = nil
+ end
{ :price => find_price_at_end(text), :url => url }
else
{ :price => NOT_AVAILABLE, :url => url }

0 comments on commit c40d7d2

Please sign in to comment.