0

I just started learning parsing and am having problems with it ... I need to scrape this value from here, but I don't know what I should write in the findElement function enter image description here

here is my code

library(RSelenium)
rD <- rsDriver(browser="chrome",port=0999L, 
               verbose=F,chromever = "95.0.4638.54")
remDr <- rD[["client"]]

remDr$navigate("https://www.valutrades.com/en/sentiment")
webElem <- remDr$findElement(using = "......", value = "......")

Can someone help me with that ?

mr.T
  • 181
  • 2
  • 13

1 Answers1

1

The data you want to scrape is in iframe.

enter image description here

One way to do is,

remDr$navigate('https://csi2.valutrades.com/sentimentgraph.php')
webElem <- remDr$findElement('xpath', '//*[@id="EURUSD"]')
webElem$getElementText()
[[1]]
[1] "EURUSDLongShort44.3%55.7%"
Nad Pat
  • 3,129
  • 3
  • 10
  • 20
  • Thanks a lot, everything worked! Can you explain how you understood that this is an "iframe" and how you got the link to it – mr.T Nov 07 '21 at 07:18
  • 1
    Edited the post. You can see the `iframe` element and the link beside it. You can also refer https://stackoverflow.com/questions/41290620/click-on-cross-domain-iframe-element-using-rselenium on other ways to deal with `iframe`. – Nad Pat Nov 07 '21 at 07:26