Estimados

Pude encontrar uno de mis errores, el cuál está en el XPath, en rvest funciona 
y comparto el código, pero por alguna causa solucionando el XPath RSelenium 
falla informando el mismo error.


library("rvest")
# Cargo la página
Pagina.R <- html(x = "http://www.r-project.org";)
## mirar bien los XPath    - los modifico, quitar el [1], no me interesa el 
primero, quiero todos
#   /html/body/div/div[1]/div[1]/div/div[1]/ul/li[1]
#   /html/body/div/div[1]/div[1]/div/div[1]/ul/li[1]/a


# tomar link URLs
urls <- Pagina.R %>% # desde Pagina.R realizar el siguiente paso
  html_nodes(xpath='/html/body/div/div[1]/div[1]/div/div[1]/ul/li/a') %>%
  html_attr("href") # extraer URLs
# Get link text
links <- Pagina.R %>% # desde Pagina.R realizar el siguiente paso
  html_nodes(xpath='/html/body/div/div[1]/div[1]/div/div[1]/ul/li') %>%
  html_text() # extraer link texto
# Combinar `links` y `urls` en un data.frame
Resultado <- data.frame(links = links, urls = urls, stringsAsFactors = FALSE)
Resultado






Javier Rubén Marcuzzi
Técnico en Industrias Lácteas
Veterinario





De: Javier Ruben Marcuzzi
Enviado el: ‎miércoles‎, ‎22‎ de ‎julio‎ de ‎2015 ‎11‎:‎56‎ ‎p.m.
Para: [email protected]





Estimados, les envío un código, el cuál me da error, aunque dudo si está 
escrito correctamente puesto que muchos ejemplos me están fallando.




Agradezco si alguno me informa un error al igual que el informado por mi 
computadora, no creo que el inconveniente sea por la opción de R que instalé en 
Windows 8.1, ya me perdí buscando mi error.




Revolution R Open 8.0.3
Using CRAN snapshot taken on 2015-04-01







library(RSelenium)
checkForServer()
startServer()





remDr <- remoteDriver()
remDr$open()
remDr$navigate("http://www.r-project.org";)




webElems <- remDr$findElement(using = 'css selector', " body > div > div.row > 
div.col-xs-12.col-sm-offset-1.col-sm-2.sidebar > div > div:nth-child(1) > ul")




resHeaders <- unlist(lapply(webElems, function(x){x$getElementText()}))
########################################################################
#Error in x$getElementText : object of type 'closure' is not subsettable
########################################################################






Javier Rubén Marcuzzi
Técnico en Industrias Lácteas
Veterinario
        [[alternative HTML version deleted]]

_______________________________________________
R-help-es mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-help-es

Responder a