我正在抓取一个网站,但是一行一行地迭代太长了。有没有什么方法可以代替迭代,只读取整个表
这是我的代码:
table = driver.find_elements_by_xpath("//table[@id='tblDocumentosEnviados']//tr")
for row in range(len(table)):
try:
WebDriverWait(driver, 2).until(EC.element_to_be_clickable((By.XPATH,
"//table[@id='tblDocumentosEnviados']//tr[" + str(
row) + "]//td[text()='Rendimentos e Amortizações']/following-sibling::td[.//span[text()='Ativo']]/following-sibling::td//a[@title='Download do Documento']"))).click()
这是我正在浏览的网站: https://fnet.bmfbovespa.com.br/fnet/publico/abrirGerenciadorDocumentosCVM
您已经将
table
作为变量。您不需要使用驱动程序进一步查找每一行例如,可以使用BeautifulSoup来解析表格文本
您可以从表中创建数据帧
相关问题 更多 >
编程相关推荐