Findelements using RSelenim


#1

I am trying to click on the Rising button on the web page "https://trends.google.com/trends/explore?geo=US&q=ABUNDANCE" using R Selenium

By inspecting the source code I found it to be of the class "_md-text" . So to find the elements associated with this class I wrote the following code.

library(RSelenium)
rs <- rsDriver()
rsc <- rs$client
rsc$navigate("https://trends.google.com/trends/explore?geo=US&q=ABUNDANCE")

ele<- rsc$findElements(using = "css","._md-text")
res <- unlist(lapply(ele, function(x){x$getElementText()}))
res

The output I got was

Capture

The name "Rising" is not there in the list.

Can anyone please tell what is the error


#2

The button for "Rising" is a custom widget, which would make it difficult to trigger all of the underlying elements simultaneously/in the correct order. (It is likely done this way to prevent web scrapping.)

Have you checked out the gtrendsR package? I haven't used it, but it might an easier solution than scrapping.