Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

231
Visualizações
Rselenium - cannot download spreadsheet in iframe

I am trying to download soil fertility data from the following website:

https://soilhealth.dac.gov.in/publicreports/FertilityIndex

I have got to the point where I can load the spreadsheet containing the data within an iframe. However I cannot figure out how to access the download button. This is the code I have so far:

rD <- rsDriver(browser="firefox", port=4536L, verbose=F)
remDr <- rD[["client"]]

remDr$navigate("https://soilhealth.dac.gov.in/publicreports/FertilityIndex")

remDr$executeScript("document.getElementById('CycleId').value = 1;")

state_elem <- remDr$findElement(using = "id", value = "State_Code")
state_opts <- state_elem$selectTag()

state_script="document.getElementById('State_Code').onchange=GetDistrict(xx);
              document.getElementById('State_Code').value = xx;"
dist_script="document.getElementById('District_Code').onchange=GetSubdistrict(xx);
            document.getElementById('District_Code').value = xx;"
sub_dist_script="document.getElementById('sub_district_code').onchange=GetVillage(xx);
                document.getElementById('sub_district_code').value = xx;"

for (s in 2:length(state_opts$value)){
  remDr$executeScript(gsub("xx", state_opts$value[3], state_script, fixed = TRUE))


  dist_elem <- remDr$findElement(using = "id", value = "District_Code")

  dist_opts <- dist_elem$selectTag()
  
  for (d in 2:length(dist_opts$value)){
    remDr$executeScript(gsub("xx", dist_opts$value[2], dist_script, fixed = TRUE))
    
    sub_dist_elem <- remDr$findElement(using = "id", value = "sub_district_code")
    
    sub_dist_opts <- dist_elem$selectTag()
    
    for (j in 2:length(sub_dist_opts$value)){
      remDr$executeScript(gsub("xx", sub_dist_opts$value[2], sub_dist_script, fixed = TRUE))
      
      remDr$findElement(using = "css", value = "#confirmLink")$clickElement()
      Sys.sleep(5)
      
      table <- remDr$findElements(using = "css", "iframe")
      remDr$switchToFrame(table[[1]])
      
      remDr$findElement(using = "css", title="#CSV")$clickElement()
      
    }
  }
}

Any help would be much appriciated!

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

After you have filled the form we can download the data in csv format by first clicking on save button and then on csv option

# click save button 
remDr$findElement(using = "xpath",'//*[@id="ReportViewer1_ctl05_ctl04_ctl00_ButtonImgDown"]')$clickElement()

#click csv option 
remDr$findElement(using = "xpath",'//*[@id="ReportViewer1_ctl05_ctl04_ctl00_Menu"]/div[7]/a')$clickElement()
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda