From: Pen Ttt on 25 Mar 2010 10:44 the following programme can run successfully,i can get a table require 'hpricot' require 'open-uri' doc = Hpricot(open('http://webbbs.gamer.com.tw/board.php?brd=Chat&p=1')) tab = (doc/'table[@class="ssize"]') (tab/'tr').each_with_index do |line,index| next if (index + 1) %2 == 0 (line/'td').each do |data| print data.inner_text.gsub("\n", '') + ' ' end puts '' end when i change an other web (there is a table in it too) i revise the programme require 'hpricot' require 'open-uri' doc = Hpricot(open('http://quotes.money.163.com/corp/1034/code=601398.html')) tab = (doc/'table[@class="ssize"]') (tab/'tr').each_with_index do |line,index| next if (index + 1) %2 == 0 (line/'td').each do |data| print data.inner_text.gsub("\n", '') + ' ' end puts '' end now , i can get nothing,how to revise it to get the table ? please open it with your brower,then you can see the table ,what i want to do is to get the data of the table , to analyse. http://quotes.money.163.com/corp/1034/code=601398.html -- Posted via http://www.ruby-forum.com/.
|
Pages: 1 Prev: WhiteBoard Class (for these Boids) Next: Threading an email queueing system |