试试这个:
library(rvest)
url <- "https://www.wikidata.org/w/index.php?title=Special:WhatLinksHere/Q5&limit=500"
s <- html_session(url)
liste <- list()
for (i in 1:2) {
data <-
s %>%
read_html() %>%
html_nodes("#mw-whatlinkshere-list li")
# There was a mistake here. You were overwriting your results
liste <- c(liste, data)
# Here you have to pass a 'a' tag, not a 'href' value. Besides,
# there is two 'next 500' tags. They are the same, but you have
# to pick one.
s <- s %>%
follow_link(xpath = "//a[text()='next 500'][1]")
}