I have a Python script which login on a page (sso.acesso.gov.br) using some credentials and them usually answer a captcha using 2Captcha API.
The problem is that recently it takes an error after captcha answer, even when I answer it manually. By the way, the error message received is different than when I forced answer wrong, which makes me believe that my script has now being detected somehow by the website.
If I open a Chrome browser as a user and just do the same steps, I can login, sometimes even without captcha. And all times without an error.
Here is my code:
from selenium import webdriver
from fake_useragent import UserAgent
import undetected_chromedriver as uc
from fp.fp import FreeProxy
user_path = 'C:\\PythonProjects\\User Data'
driver_path = 'C:\\PythonProjects\\107\\chromedriver.exe'
options = webdriver.ChromeOptions()
## Tactics to avoid being detected as automation
options.add_argument("--start-maximized")
options.add_argument('--disable-blink-features=AutomationControlled')
## User profile
options.add_argument(f"--user-data-dir={user_path}")
## User agent
ua = UserAgent()
options.add_argument(f'--user-agent={ua.random}')
## Proxy
proxy = FreeProxy().get()
options.add_argument(f'--proxy-server={proxy}')
## Set browser
driver = uc.Chrome(
driver_executable_path = driver_path,
options = options
)
## Set device memory info
driver.execute_script("Object.defineProperty(navigator, 'deviceMemory', {get: () => 8});")
## Set navigator webdriver to undefined
driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined});")
## Open page
driver.get('https://sso.acesso.gov.br/login')
## From this point I insert CPF (user) and password, then answer captcha using 2Captcha
## I also have tried just set the browser and navigate manually, inserting data and answering captcha, but no success
Do you have any suggestion to bypass this block? I have no idea about what is detecting and blocking my browser.
If I use my script on bot.sannysoft.com, I get the following results: