Это мой первый проект на python, и я не могу получить результат исследования на веб-сайте ASPX и затем поместить его в файл XLSX, может кто-нибудь мне помочь?
Это мой код:
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import openpyxl
from openpyxl import load_workbook
driver = webdriver.Chrome(executable_path=r'C:\Python37\webdriver\chromedriver.exe')
driver.get("https://www3.cfc.org.br/SPw/ConsultaNacional/ConsultaCadastralCFC.aspx")
planilha = openpyxl.load_workbook('BASE 05-09.xlsx')
sheet = planilha['Aba1']
for Count in range(2,5552):
box_cpf = driver.find_element_by_xpath(".//*[@id='ctl00_ContentPlaceHolder1_TxtCpf']")
box_cpf.send_keys(sheet.cell(row=Count, column=5).value)
time.sleep(0)
pesquisar_bto = driver.find_elements_by_id("ctl00_ContentPlaceHolder1_btPesquisar")[0]
pesquisar_bto.click()
resultado_pesquisa = driver.find_element_by_xpath("/html/body/form/div[3]/div[2]/div/table[2]/tbody/tr[4]/td/table[3]/tbody/tr/td/table[1]/tbody/tr[2]/td[2]")
sheet.cell(row=Count, column=6).value = resultado_pesquisa
time.sleep(0)
limpar_bto = driver.find_elements_by_id("ctl00_ContentPlaceHolder1_btLimpar")[0]
limpar_bto.click()
planilha.save("BASE 05-09.xlsx")
это ошибка:
ValueError: Cannot convert <selenium.webdriver.remote.webelement.WebElement (session="7dbf3fdcf12fe678381e94bc81eefb97", element="9af52fc6-7f28-4963-b1e8-5ecb6bdc0cd1")> to Excel
Ошибка:
