r - lapply function with RSelenium -
my session this:
startserver() remdir <- remotedriver() remdir$open() source <- paste0("https://www.example.com") remdir$navigate(source)
i parsing link:
html <- remdir$getpagesource() tmp <- xpathsapply(htmlparse(html[[1]]), ' //a/@href')
and want parse each tmp link:
srcpartone <- paste0(source, as.list(tmp)[185:199],"/") htmls <- lapply(srcpartone, geturl)
but in point, geturl function not usage me. because links contains dynamic page. so, need use rselenium in lapply
function this:
htmls <- lapply(srcpartone, remdir$navigate,remdir$pagesource)
i gave example, know doesn't work. how can parse each link using rselenium? edit :
library(rselenium) library(rcurl) library(rdrop2) library(pbapply) #start rselenium drop_auth() #dropbox authentication startserver() remdir <- remotedriver() remdir$open(silent = true) #set 'vitrin' sources mobil number: source <- paste0("https://www.sah1b1nden.com") remdir$navigate(source) html <- remdir$getpagesource() tmp <- xpathsapply(htmlparse(html[[1]]), ' //a/@href') #get html framework each ' vitrin' sources: # srcpartone <- paste0(source, as.list(tmp)[185:232],"/") pblapply(srcpartone, function(x) { remdir$navigate(x) remdir$getpagesource() }) -> pgs parses<- lapply(x = pgs[1:48], htmlparse) temp <- lapply(parses, xpathsapply, '//*[contains(concat( " ", @class, " " ), concat( " ", "show-part", " " ))]',xmlvalue)
Comments
Post a Comment