Rails报废价格

时间:2015-12-01 06:22:56

标签: ruby-on-rails ruby web-scraping mechanize

我正在开发一个rails应用程序,因为我必须从链接中取消价格,但无法这样做link

mechanize=Mechanize.new
     page = mechanize.get('url') 
     doc=page.parser
     #seller price
     puts doc.css('div.olpOffer div.a-span2 span.currencyINRFallback').text

1 个答案:

答案 0 :(得分:1)

价格嵌套在上面的范围内。

mechanize=Mechanize.new
  page = mechanize.get('http://www.amazon.in/gp/offer-listing/B00WER132G/ref=olp_page_1?ie=UTF8&qid=1448947981&sr=1-12') 
  doc=page.parser
  #seller price
  puts doc.css('div.olpOffer div.a-span2 span.olpOfferPrice').text

Per pguardiarit的评论..

mechanize=Mechanize.new
page = mechanize.get('http://www.amazon.in/gp/offer-listing/B00WER132G/ref=olp_page_1?ie=UTF8&qid=1448947981&sr=1-12')
#seller price  
puts page.css('div.olpOffer div.a-span2 span.olpOfferPrice').text