I’m trying to automate a procedure that i enter in a public website, from the brazilian government, and collect some public data from some companies. But when i am entering with selenium in the website i discover that it has a hidden captcha and idk how can i enter the website and insert the ID from the companies that i was searching.
In the first place i tried to enter with selenium and insert the ID to collect the data, but the website show a text “Prevented by Captcha protection. Robot Behavior.” but what i am trying to do is to simple automate a process that a person insert manually, catch the data and insert in some sheet.
When i look for the HTML i see that there was a hidden “hCaptcha”
<div class="h-captcha" data-sitekey="96a07261-d2ef-4959-a17b-6ae56f256b3f" data-callback="onSubmit" data-hcaptcha-source-id="button[data-hcaptcha-widget-id='018rf9z74lbc']" style="display: none;"><iframe aria-hidden="true" data-hcaptcha-widget-id="018rf9z74lbc" data-hcaptcha-response="" style="display: none;"></iframe><textarea id="h-captcha-response-018rf9z74lbc" name="h-captcha-response" style="display: none;"></textarea></div>
theres the code that i am trying to create to solve my problem
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import time
options = Options()
options.binary_location = r'C:Program FilesMozilla Firefoxfirefox.exe'
options.headless = False
driver = webdriver.Firefox(options=options)
def enter_Gov(cnpj):
driver.get("http://www8.receita.fazenda.gov.br/simplesnacional/aplicacoes.aspx?id=21")
time.sleep(5)
iframe = driver.find_element(By.XPATH, "//iframe[@src='/SimplesNacional/Aplicacoes/ATBHE/ConsultaOptantes.app/']")
driver.switch_to.frame(iframe)
cnpj_input = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#Cnpj')))
cnpj_input.clear()
cnpj_input.send_keys(cnpj)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '/html/body/div[1]/div[2]/form/button'))).click()
time.sleep(10)
CNPJ_list = ['33592510000154', '33000167000101']
for cnpj in CNPJ_list:
enter_Gov(cnpj)