Have a look at this webpage. I want to extract the text element '2013'. I use RSelenium for this, but if anyone knows how to do it using any other package that is fine too. My current script is the following:
startServer()
remDr <- remoteDriver(browserName="chrome")
remDr$open(silent=T)
remDr$navigate(as.character(url))
remDr$findElement("css selector","#crosstable > table > tbody > tr:nth-child(2) > th:nth-child(2)")$getElementText()
This gives following error:
Error: Summary: NoSuchElement
Detail: An element could not be located on the page using the given search parameters.
class: org.openqa.selenium.NoSuchElementException
The first thing I noted was that it is not possible to select this short piece of text using selectorgadget. So I want looking for the piece of text in the source code and copied its specific selector path: #crosstable > table > tbody > tr:nth-child(2) > th:nth-child(2)
. But as the error shows, this does not work.
I am new to webscraping and have almost no html knowledge, so any clue on how to extract the text "2013" from the table is welcome.
EDIT - I found ow how to it
startServer()
remDr <- remoteDriver(browserName="chrome")
remDr$open(silent=T)
remDr$navigate(as.character(url))
webElem <- remDr$findElement("id", "content_iframe")
remDr$switchToFrame(webElem)
webElem <- remDr$findElement("id", "passthrough")
remDr$switchToFrame(webElem)
remDr$findElement("xpath",'//*[@id="crosstable"]/table/tbody/tr[2]/th[2]')$getElementText()