I am trying to fetch the text data(eg. dealer type, dealer name) from google map URL. I have written following code for this:
library(RSelenium)
library(XML)
library(xlsx)
test<-read.xlsx("C:\\Selenium_Tool\\Segmentaion_Files\\test.xlsx",1)
test$addr<-paste(test$CUST_ADDRESS,test$CUST_CITY, test$CUST_STATE,sep =
",")
test$URL<-paste("https://www.google.co.in/maps/place/",test$addr)
View(test)
rd<-rsDriver(port = 4567L, browser = c("chrome", "firefox", "phantomjs",
"internet explorer"), version = "latest", chromever = "latest", geckover =
"latest", iedrver = NULL, phantomver = "2.1.1", verbose = TRUE, check =
TRUE)
remDr <- rd[["client"]]
for(i in 1:length(test$CUST_ID)) {
remDr$navigate(test$URL[i])
webElem<-remDr$findElements(using = 'class','section-listbox')
elem<-webElem[1]
class(elem)
test$result[i]<-elem$getElementText()[[1]]
}
remDr$close()
rd[["server"]]$stop()
In test.xlsx, I have few google map URLs. when I am trying to run this code for 100 URL's, it is working fine but when I am running this for more than 100 URL's, it is giving me error stating: Error in webElem[[1]] : subscript out of bounds
Please help me to sort this out.