I have been able to extract the numbers with the following code :
library(RSelenium)
shell('docker run -d -p 4446:4444 selenium/standalone-firefox')
remDr <- remoteDriver(remoteServerAddr = "localhost", port = 4446L, browserName = "firefox")
remDr$open()
remDr$navigate("https://bioportal.bioontology.org/ontologies/MEDDRA?p=classes&conceptid=10040786")
remDr$screenshot(TRUE)
Sys.sleep(3)
web_Obj_Plus_Sign <- remDr$findElement('xpath', '/html/body/div[1]/div[2]/div[5]/div/div/div[2]/div/div[2]/div[2]/div[1]/div[2]/div/ul/li/ul/li[2]/img')
web_Obj_Plus_Sign$clickElement()
list_Url <- list()
for(i in 1 : 100)
{
print(i)
xpath <- paste0('/html/body/div[1]/div[2]/div[5]/div/div/div[2]/div/div[2]/div[2]/div[1]/div[2]/div/ul/li/ul/li[2]/ul/li[', i * 2, ']/a')
web_Obj_Link <- tryCatch(remDr$findElement("xpath", xpath), error = function(e) NA)
if(is.na(web_Obj_Link))
{
break
}else
{
list_Url[[i]] <- web_Obj_Link$getElementAttribute("href")[[1]]
}
}
MEDDRA_Number <- unlist(lapply(X = list_Url, FUN = function(x) tail(strsplit(x, "%")[[1]], 1)))
MEDDRA_Number
1] "2F10000318" "2F10000513" "2F10075963" "2F10059136" "2F10049044" "2F10005192" "2F10051548" "2F10007247"
[9] "2F10074010" "2F10012470" "2F10065259" "2F10060803" "2F10014141" "2F10014199" "2F10015146" "2F10057211"
[17] "2F10021531" "2F10063866" "2F10071367" "2F10050500" "2F10021784" "2F10065487" "2F10054994" "2F10073621"
[25] "2F10076139" "2F10061303" "2F10061304" "2F10051296" "2F10054019" "2F10087209" "2F10069447" "2F10037578"
[33] "2F10037632" "2F10085875" "2F10037888" "2F10069443" "2F10040855" "2F10040872" "2F10042343" "2F10085173"
[41] "2F10055027" "2F10067653" "2F10066047