[R] Re ad HTML table

f.jamitzky f.jamitzky at gmail.com
Mon Nov 19 00:38:07 CET 2007


You can use htmlTreeParse and xpathApply from the XML library.
something like:

xpathApply( htmlTreeParse("http://blabla", useInt=T), "//td", function(x)
xmlValue(x))

should do it.



Gamma wrote:
> 
> anyone care to explain how to read a html table, it's streaming data
> (updated every second) and i am looking for a suitable function.
> 
> The imported html tables looks like this:
> 
> [1] "<body><html><table>"
> [2] "<tr><td>SEQUENCE</td> <td>EXCHANGE</td> <td>BOARD</td> <td>TIME</td>
> <td>PAPER</td> <td>BID</td> <td>BID-DEPTH</td> <td>BID-DEPTH-TOTAL</td>
> <td>BID-NUMBER</td> <td>OFFER</td> <td>OFFER-DEPTH</td>
> <td>OFFER-DEPTH-TOTAL</td> <td>OFFER-NUMBER</td> <td>OPEN</td>
> <td>HIGH</td> <td>LOW</td> <td>LAST</td> <td>CHANGE</td>
> <td>CHANGE-PERCENT</td> <td>VOLUME</td> <td>VALUE</td> <td>TRADES</td>
> <td>STATUS</td></tr>"
> [3]"<tr><td>184311995</td><td>ST</td><td></td><td>174336</td><td>SX50PI</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>953.9600</td><td>937.9800</td><td>947.5900</td><td>2.6000</td><td>0.2751</td><td></td><td></td><td></td><td></td></tr>"  
> and so on to the table closing brackets. 
> 
> [15] "</table></html></body>"  
> 
> 
> Tried a few commands but i only get html code back, like above:
> readLines(url("")), socketConnection() and url() and nothing seemingly
> useful comes up with apropos("html") either.
> 
> 
> Regards
> 

-- 
View this message in context: http://www.nabble.com/Read-HTML-table-tf4832010.html#a13825471
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list