1
rvestパッケージを使用して、input type = "radio"タグに格納され、次にTAG span class = "glyphicon glyphicon-ok"に格納されているテキストを読むことは可能ですか?例えば:私はrvestを使用してHTMLから読み取る
Rコード#doesがp_ansに格納されて
install.packages('rvest')
library('rvest')
url <- 'http://upscfever.com/upsc-fever/en/test/en-test-sci1.html'
webpage <- read_html(url)
p_ans <- webpage %>%
html_nodes("input + glyphicon-ok") %>%
html_text()
HTMLコード
<div class="form-group" id="myform">
<label for="usr">Q1: Energy giving foods are </label>
</div>
<div class="radio">
<label><input type="radio" value="1" name="optradio0">Carbohydrates and fats<span class="glyphicon glyphicon-ok"></span></label>
</div>
<div class="radio">
<label><input type="radio" id="opt1" value="-0.33" name="optradio0">Carbohydrates and Proteins<span id="sp1" class="glyphicon glyphicon-remove"></span></label>
</div>
を仕事とNAを与えていない文字ベクトルで "炭水化物と脂肪を" 読みたいですその特定のクイズのすべての正解をキャッチする全く巧妙な方法;-) – hrbrmstr