Im trying to scrape data from this website: https://www.rad.cvm.gov.br/ENETCONSULTA/frmGerenciaPaginaFRE.aspx?NumeroSequencialDocumento=102142&CodigoTipoInstituicao=2, but switching from "Demonstração do Resultado" to "Balanço Patrimonial Ativo" on the upper right box, the whole table is under the CSS selector "#ctl00_cphPopUp_tbDados" but I cant get the data using selenium webdriver, I think the table is dynamic and loads under a script, but I don't know other way to get this data. Here is the complete code so far:
cvm = input('Códigos CVM separados por vírgula: ')
lstcvm = list(map(str,cvm.split(',')))
for i in lstcvm:
url="https://bvmf.bmfbovespa.com.br/cias-listadas/empresas-listadas/ResumoDemonstrativosFinanceiros.aspx?codigoCvm="+i+"&idioma=pt-br"
driver = webdriver.Firefox()
driver.get(url)
dfp = driver.find_element(By.CSS_SELECTOR, "#ctl00_contentPlaceHolderConteudo_rptDocumentosDFP_ctl00_lnkDocumento")
webdriver.ActionChains(driver).click(dfp).perform()
time.sleep(10)
tabs=driver.window_handles
driver.switch_to.window(tabs[1])
print(driver.current_url)
box = driver.find_element(By.CSS_SELECTOR, "#cmbQuadro")
box.send_keys(Keys.HOME, Keys.RETURN)
time.sleep(1)
driver.maximize_window()
time.sleep(1)
balanco=driver.find_element(By.CSS_SELECTOR, "#ctl00_cphPopUp_tbDados").text
balanco
driver.switch_to.window(tabs[0])
print(driver.current_url)
print("Finalizado")
The sample input here is 9512
The portion of the code used trying to scrape the data is this one:
balanco=driver.find_element(By.CSS_SELECTOR, "#ctl00_cphPopUp_tbDados").text