I am writing a scraper in Python and ran into a CAPTCHA on the login form. The site sometimes returns a regular reCAPTCHA v2 and sometimes hCaptcha. I tried to bypass this through Selenium, but CAPTCHA keeps blocking the automation.
My purpose is to automatically obtain the CAPTCHA solution token and insert it into the form so that the script can continue running without manual involvement.
What I have already tried: headless Chrome, different user agents; waiting for the iframe to appear; tried recognizing the CAPTCHA image through third-party libraries, but reCAPTCHA/hCaptcha do not work this way; found mentions of external services, but I do not understand how exactly to integrate them with Python via API.
What I need:
A step-by-step recommendation on how to technically organize CAPTCHA solving in Python: which API to use; how to create a task, obtain the token; how to pass it back into Selenium or the request; whether a universal method exists for different CAPTCHA types.
I would appreciate an example of working code or a proven architecture.