Using Nokogiri to scrape a value from Yahoo Finance?
问题 I wrote a simple script: require 'rubygems' require 'nokogiri' require 'open-uri' url = "http://au.finance.yahoo.com/q/bs?s=MYGN" doc = Nokogiri::HTML(open(url)) name = doc.at_css("#yfi_rt_quote_summary h2").text market_cap = doc.at_css("#yfs_j10_mygn").text ebit = doc.at("//*[@id='yfncsumtab']/tbody/tr[2]/td/table[2]/tbody/tr/td/table/tbody/tr[11]/td[2]/strong").text puts "#{name} - #{market_cap} - #{ebit}" The script grabs three values from Yahoo finance. The problem is that the ebit XPath