{"id":20710009,"url":"https://github.com/oxylabs/selenium-bypass-captcha","last_synced_at":"2025-09-27T11:30:22.597Z","repository":{"id":199719448,"uuid":"703536657","full_name":"oxylabs/selenium-bypass-captcha","owner":"oxylabs","description":"See how to easily bypass CAPTCHA tests using Selenium in Python.","archived":false,"fork":false,"pushed_at":"2024-04-19T10:59:25.000Z","size":716,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-17T02:09:28.458Z","etag":null,"topics":["bypass-captcha","captcha","captcha-bypass","python","selenium","selenium-python","web-scraping"],"latest_commit_sha":null,"homepage":"https://oxylabs.io/blog/selenium-bypass-captcha","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oxylabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-10-11T12:30:50.000Z","updated_at":"2024-09-24T02:21:32.000Z","dependencies_parsed_at":"2024-04-19T12:03:42.892Z","dependency_job_id":null,"html_url":"https://github.com/oxylabs/selenium-bypass-captcha","commit_stats":null,"previous_names":["oxylabs/selenium-bypass-captcha"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fselenium-bypass-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fselenium-bypass-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fselenium-bypass-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fselenium-bypass-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxylabs","download_url":"https://codeload.github.com/oxylabs/selenium-bypass-captcha/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234429243,"owners_count":18831240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bypass-captcha","captcha","captcha-bypass","python","selenium","selenium-python","web-scraping"],"created_at":"2024-11-17T02:09:32.439Z","updated_at":"2025-09-27T11:30:22.588Z","avatar_url":"https://github.com/oxylabs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to Bypass CAPTCHA With Selenium \u0026 Python\n\n[![mubeng](https://raw.githubusercontent.com/oxylabs/product-integrations/refs/heads/master/Affiliate-Universal-1090x275.png)](https://github.com/oxylabs/web-unblocker)\n\n[![](https://dcbadge.limes.pink/api/server/Pds3gBmKMH?style=for-the-badge\u0026theme=discord)](https://discord.gg/Pds3gBmKMH) [![YouTube](https://img.shields.io/badge/YouTube-Oxylabs-red?style=for-the-badge\u0026logo=youtube\u0026logoColor=white)](https://www.youtube.com/@oxylabs)\n\n- [Bypass CAPTCHA with Selenium and Python](#bypass-captcha-with-selenium-and-python)\n  * [**Step 1 - Install dependencies**](#step-1---install-dependencies)\n  * [**Step 2 - Import libraries**](#step-2---import-libraries)\n  * [**Step 3 - Navigate to webpage**](#step-3---navigate-to-webpage)\n  * [**Step 4 - Take a screenshot**](#step-4---take-a-screenshot)\n- [**Bypass CAPTCHA with Web Unblocker**](#bypass-captcha-with-web-unblocker)\n  * [**Step 1 - Import libraries**](#step-1---import-libraries)\n  * [**Step 2 - Get Web Unblocker credentials**](#step-2---get-web-unblocker-credentials)\n  * [**Step 3 - Prepare Web Unblocker**](#step-3---prepare-web-unblocker)\n  * [**Step 4 - Fetch content**](#step-4---fetch-content)\n\nIn this tutorial, you’ll learn how to handle CAPTCHA tests in Selenium\nand Python using\n[\u003cu\u003eundetected-chromedriver\u003c/u\u003e](https://github.com/ultrafunkamsterdam/undetected-chromedriver)\nand [\u003cu\u003eOxylabs’ Web\nUnblocker\u003c/u\u003e](https://oxylabs.io/products/web-unblocker). See the\n[\u003cu\u003efull blog post\u003c/u\u003e](https://oxylabs.io/blog/selenium-bypass-captcha)\nfor more details and tips.\n\n## Bypass CAPTCHA with Selenium and Python\n\nThe first step is to install Python if you haven't installed it already.\nYou can download it from the [\u003cu\u003eofficial\nwebsite\u003c/u\u003e](https://python.org/download). Download the latest version\nor a version greater than 3.6; otherwise, undetected-chromedriver won’t\nwork properly.\n\n### Step 1 - Install dependencies\n\nInstall the **undetected-chromedriver** and **requests** module. You can use the\n`pip` command given below:\n\n```bash\npip install undetected-chromedriver requests\n```\n\n### Step 2 - Import libraries\n\nNow that you’ve installed undetected-chromedriver, you can import it as\nshown below:\n\n```python\nimport undetected_chromedriver as webdriver\n\nchrome_options = webdriver.ChromeOptions()\nchrome_options.add_argument(\"--headless\")\nchrome_options.add_argument(\"--use_subprocess\")\n\nbrowser = webdriver.Chrome(options=chrome_options)\n```\n\nNotice, you’ve also created a `browser` instance. This will open a\nChrome window in the background in `headless` mode.\n\n### Step 3 - Navigate to webpage\n\nUse the `browser` instance to navigate to your target website. For\nthis tutorial, let’s use\n[\u003cu\u003ehttps://sandbox.oxylabs.io/products\u003c/u\u003e](https://sandbox.oxylabs.io/products)\nas the target.\n\n```python\nbrowser.get(\"https://sandbox.oxylabs.io/products\")\n```\n\n### Step 4 - Take a screenshot\n\nTake a screenshot to verify the page is loaded properly without showing\nany CAPTCHA or bot protection screen. You can use the\n`save_screenshot` method of Selenium.\n\n```python\nbrowser.save_screenshot(\"screenshot.png\")\n```\n\nYour screenshot might vary slightly due to screen size, but it’ll look\nsimilar to the one given below:\n\n![Screenshot](images/screenshot.png)\n\nThe page has loaded properly without showing any CAPTCHA and the\nundetected-chromedriver has rendered the Javascript files.\n\n## Bypass CAPTCHA with Web Unblocker\n\nTo perform large-scale web scraping while bypassing CAPTCHA, you’ll need\na strong tool. [\u003cu\u003eWeb\nUnblocker\u003c/u\u003e](https://oxylabs.io/products/web-unblocker), an AI–powered\nproxy solution for bypassing IP blocks and CAPTCHAs, will automatically\nrotate proxies for you, so you don’t have to worry about manually\nmanaging a list of proxies for your bots.\n\n### Step 1 - Import libraries\n\nLet’s use the `requests` module to set up Web Unblocker.\n\n```python\nimport requests\n```\n\n### Step 2 - Get Web Unblocker credentials\n\n[\u003cu\u003eCreate an account\u003c/u\u003e](https://dashboard.oxylabs.io/en/) to get the Web Unblocker credentials. Within a few\nclicks, you can sign up and get a **1-week free trial** to develop and\nthoroughly test the solution.\n\n### Step 3 - Prepare Web Unblocker\n\nWeb Unblocker’s host and port are `unblock.oxylabs.io` and `60000`\nrespectively. Additionally, don’t forget to replace the `USERNAME` and\n`PASSWORD` with the correct credentials.\n\n```python\nproxy = 'http://{}:{}@unblock.oxylabs.io:60000'.format(\"USERNAME\", \"PASSWORD\")\n\nproxies = {\n    'http': proxy,\n    'https': proxy\n}\n```\n\nIf you get any authentication-related errors in the later steps, don’t\nforget to check the Web Unblocker response codes\n[\u003cu\u003ehere\u003c/u\u003e](https://developers.oxylabs.io/advanced-proxy-solutions/web-unblocker/response-codes).\n\n### Step 4 - Fetch content\n\nNow, you can use the `proxies` dict you created with the `get`\nmethod of the `requests` module. Web Unblocker also requires you to\npass an extra parameter, `verify=False`, to the get method.\n\n```python\npage = \"https://sandbox.oxylabs.io/products\"\nresponse = requests.get(page, proxies=proxies, verify=False)\n\nprint(response.status_code)\ncontent = response.content\n```\n\nYou should see the status code `200` if everything works as expected.\nThe content of the page will be stored in the `content` object, which\nyou can process later with HTML Parser libraries such as [\u003cu\u003eBeautiful\nSoup\u003c/u\u003e](https://www.crummy.com/software/BeautifulSoup/bs4/doc/) or\nparse using the [\u003cu\u003eCustom\nParser\u003c/u\u003e](https://developers.oxylabs.io/scraper-apis/custom-parser).\nWeb Unblocker also renders JavaScript for you, so you can use this\nmethod for dynamic websites as well.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fselenium-bypass-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxylabs%2Fselenium-bypass-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fselenium-bypass-captcha/lists"}