I am trying to use the rvest package to clear data from a web page. In simple format, the html code is as follows:
<div class="style"> <input id="a" value="123"> <input id="b"> </div>
I want to get the value 123 from the first input. I tried the following R code:
library(rvest) url<-"xxx" output<-html_nodes(url, ".style input")
This will return a list of input tags:
[[1]] <input id="a" value="123"> [[2]] <input id="b">
Next, I tried using html_node to refer to the first input tag by id:
html_node(output, "
Here he returned a list of zeros instead of the required input tag.
[[1]] NULL [[2]] NULL
My question is: how can I refer to an input tag using its id?
source share