Using R to scrape the link address of a downloadable file from a web page?
I think you're trying to do too much in a single xpath expression - I'd attack the problem in a sequence of smaller steps:
library(rvest)library(stringr)page <- html("http://www.acleddata.com/data/realtime-data-2015/")page %>% html_nodes("a") %>% # find all links html_attr("href") %>% # get the url str_subset("\\.xlsx") %>% # find those that end in xlsx .[[1]] # look at the first one