How to read html table with Rselenium?

I use Rselenium to go to a web page. The following code does this. I did not provide a url because I am using the url in a company that needs vpn to connect:

RSelenium::startServer() require(RSelenium) remDr <- remoteDriver() remDr$navigate("some url") 

After going to the webpage, inside the html source, I have the following table:

 <font size="2"> <table border="1"> <tbody> <tr> <td> item1 </td> <td> 0 </td> <td> 0.05 </td> <td> 2.43 </td> <td align="center"> Pct </td> <td align="center"> 1 </td> </tr> </tbody> </table> 

Now the question is, how can I pull out the contents of this table? Assume the url does not exist, otherwise I can use the XML function: readHTMLTable (remDr $ getCurrentUrl ()). But for some reason this does not work. I need to use only the remoteDriver handle (remDr). Thanks so much for your time.

+6
source share
1 answer

Sort of:

 doc <- htmlParse(remDr$getPageSource()[[1]]) readHTMLTable(doc) 

should allow you to access html and process the contained tables.

+11
source

Source: https://habr.com/ru/post/986193/


All Articles