mercredi 1 mai 2019

Obtain URLs from search using rvest in R

I am trying to obtain URLs for searches into Western Union website from Nigerian provinces. In particular, I want to search the following webpage https://locations.westernunion.com/search/nigeria/ for a vector of provinces, and for each search to keep the corresponding URL to then webscrape each of the obtained links. I know how to do the second step but not the first one. In particular, my code is

#install.packages("selectr")
#install.packages("xml2")
library(selectr)
library(xml2)
library(rvest)
library(xlsx)
provinces = as.vector(read.xlsx("provinces.xls", 1)[,1])

URL <- "https://locations.westernunion.com/search/nigeria/"
webpage <- read_html(URL)

But now I don't know how to proceed to search and store the URL for each of my provinces from the vector mentioned previously.

Any tip? Thank you a lot guys.

PS: First time posting here.




Aucun commentaire:

Enregistrer un commentaire