Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99409

ValueError: Cannot convert to Excel - Scrapper in Python

$
0
0

That's my first project in python, and i cant get the result of a research in a ASPX website and put then into a XLSX file, can someone help me?

That`s my code:

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")

that's the error:

ValueError: Cannot convert <selenium.webdriver.remote.webelement.WebElement (session="7dbf3fdcf12fe678381e94bc81eefb97", element="9af52fc6-7f28-4963-b1e8-5ecb6bdc0cd1")> to Excel

Error:

enter image description here


Viewing all articles
Browse latest Browse all 99409

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>