I have been struggling to get a piece of data using rvest. The piece of data I am looking for is the value 20960 which is insideOpenView(20960 ). How would I accomplish this with rvest?
An example section of the html I am working with is
<tr class="row-1" align="left">
<td style="width:120px;">
<a href="#" onclick='OpenView(20960 );return false;'>
BAKER, JAIME EDWARD</a>
</td>
</tr>
                I think this requires a little grepping...
library("rvest")
library("stringr")
read_html('<tr class="row-1" align="left">
<td style="width:120px;">
          <a href="#" onclick=\'OpenView(20960 );return false;\'>
          BAKER, JAIME EDWARD</a>
            </td>
            </tr>') %>% 
  html_nodes("a") %>% 
  html_attr("onclick") %>%
  str_extract("(?<=\\().*(?=\\))") %>%    # returns the stuff inside the parens
  str_trim(side="both")                   # trims whitespace from both sides
  [1] "20960"
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With