我只想从这些表和第三列(在图像、候选人名称之后)报告的选票中刮除候选人的名字。
这就是我所得到的。
library(rvest)
ndp_leadership<-url('https://en.wikipedia.org/wiki/New_Democratic_Party_leadership_elections')
results<-read_html(ndp_leadership, 'table')
results<-html_nodes(results, 'table')
out<-results %>%
html_nodes(xpath="//*[contains(., 'Candidate')]//tr/td")
out发布于 2017-11-06 20:10:40
虽然这并不真正使用XPath,但有一种方法可以做到:
results <- read_html(ndp_leadership) %>%
html_nodes(".wikitable") %>%
html_table(fill=TRUE) %>%
map(~ .[,2]) %>%
unlist %>%
setdiff(., c("Candidate", "Total"))https://stackoverflow.com/questions/47143734
复制相似问题