Junkone
(Junkone)
1
url="http://www.nasdaq.com/aspxcontent/shortinterests.aspx?
symbol=FRE&selected=FRE"
doc=open(url) {|f| Hpricot(f)}
doc.search("//table[@class='dataGrid']")
rqTable=doc.search("//table[@class='dataGrid']")
rqTable.search('tr').each{|tr|
tdArray=tr.search('td')
dataArray=Array.new
#tr.search('td').each{|td|
# puts td.inner_text
# }
puts tdArray[0].class,tdArray[1].to_s,tdArray[2]
puts "end"
}
how do i get the text value of the tdArray[0] which is internally a
Hpricot::Elem
It's often easier to simply go directly to what you want with XPath.
I'm not sure exactly what you want to extract, but try this:
require 'open-uri'
url="http://www.nasdaq.com/aspxcontent/shortinterests.aspx?
symbol=FRE&selected=FRE"
doc=Hpricot(open(url))
rqTable=doc.search("//table[@class='dataGrid']//td/text()")
puts rqTable.inspect
···
On Aug 12, 2:04 pm, Junkone <junko...@gmail.com> wrote:
url="http://www.nasdaq.com/aspxcontent/shortinterests.aspx?
symbol=FRE&selected=FRE"
doc=open(url) {|f| Hpricot(f)}
doc.search("//table[@class='dataGrid']")
rqTable=doc.search("//table[@class='dataGrid']")
rqTable.search('tr').each{|tr|
tdArray=tr.search('td')
dataArray=Array\.new
\#tr\.search\('td'\)\.each\{|td|
\# puts td\.inner\_text
\# \}
puts tdArray\[0\]\.class,tdArray\[1\]\.to\_s,tdArray\[2\]
puts "end"
}
how do i get the text value of the tdArray[0] which is internally a
Hpricot::Elem