Hi community
Im want get the data of this FB page. Im get the HTML with RSelenium
and try the nodes with rvest
.
I have problems for understand the correct nodes. Im try with xpath and css selectors.
Any suggestions for find the data of this page?
#Activar librerias
library(RSelenium)
library(XML)
library(dplyr)
library(rvest)
remDr <- remoteDriver(browserName = "chrome",port = 4444,
remoteServerAddr = "localhost")
remDr$open()
Sys.sleep(1)
remDr$navigate("https://www.facebook.com/legorafi")
Sys.sleep(2)
remDr$findElement(using = "xpath", '//*[@id="mount_0_0_3O"]/div/div[1]/div/div[4]/div/div/div[1]/div/div[2]/div/div/div/div[1]/div/i')$clickElement()
html <- remDr$getPageSource()[[1]]
pagina <- read_html(html)
titulo <- pagina %>% html_nodes(css = "div > div > span > div > div") %>% html_text()
likes <- pagina |> html_nodes(css = "span.xrbpyxo.x6ikm8r.x10wlt62.xlyipyv.x1exxlbk > span > span") %>% html_text()
shares <- pagina |> html_nodes(css = "div:nth-child(2) > span > div > div > div:nth-child(1) > span") %>% html_text()
fecha <- pagina |> html_nodes(css = "span:nth-child(2) > span > a > span") %>% html_text()
links <- pagina |> html_nodes()
Tnks!