Search code examples
ruby-on-railsrubynokogirimechanize

Rails fetching price using nokogiri and mechanize


I am trying to fetch price from several website but I am unable to do so.For example right now I am trying from snapdeal but I am failing

module HomesHelper

  require 'mechanize'
    require 'nokogiri'


def scrape
mechanize=Mechanize.new
 page = mechanize.get('http://www.snapdeal.com/product/apple-iphone-6-16-gb/1270529654') 
 doc=page.parser
price= doc.css("div #buyPriceBox  span .payBlkBig selectorgadget_selected").text
puts price
end
end

Solution

  • Try following scraping statement. Hope this works for you

     doc.css("div #buyPriceBox .pdp-e-i-PAY div.pdp-e-i-PAY-r span span.payBlkBig").text