I am using R, version 3.3.2. Using Rselenium package, I am trying to scrap some data from this website: http://www.dziv.hr/en/e-services/on-line-database-search/patents/
I am using Rselenium and my code looks like this:
selServ <- RSelenium::startServer(javaargs = c("-Dwebdriver.gecko.driver=\"C:/Users/Mislav/Documents/geckodriver.exe\""))
remDr <- remoteDriver(extraCapabilities = list(marionette = TRUE))
remDr$open()
Sys.sleep(2)
# Simulate browser session and fill out form
remDr$navigate("http://www.dziv.hr/hr/e-usluge/pretrazivanje-baza-podataka/patent/")
This doesn't work:
webel <- remDr$findElement(using = "xpath", "/input[@id = 'TB1']")
Then I wanted to swith to iframe using switchToFrame()
function, but the iframe does not contain id.
Then I have tr to use index: webel <- remDr$switchToFrame(1) but this just return NULL
Also, I recognized, iframe has different domain.
Is it possible to svrap data from this web site?
You can just select the first iframe
and pass it to the switchToFrame
method:
webElem <- remDr$findElements("css", "iframe")
remDr$switchToFrame(webElem[[1]])
webel <- remDr$findElement(using = "xpath", "//input[@id = 'TB1']")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With