{"id":27996551,"url":"https://github.com/oxylabs/playwright-captcha","last_synced_at":"2026-03-07T07:32:44.873Z","repository":{"id":276983730,"uuid":"851653173","full_name":"oxylabs/playwright-captcha","owner":"oxylabs","description":"A guide on how to use Playwright to bypass CAPTCHA challenges using Python.","archived":false,"fork":false,"pushed_at":"2025-09-25T08:38:44.000Z","size":20,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-25T10:26:44.299Z","etag":null,"topics":["captcha","playwright","playwright-python","scraping-websites"],"latest_commit_sha":null,"homepage":"","language":null,"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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-03T13:39:40.000Z","updated_at":"2025-09-25T08:38:47.000Z","dependencies_parsed_at":"2025-02-11T14:31:27.649Z","dependency_job_id":"54cd2e52-038f-4bf2-9024-4cbbbaac8aee","html_url":"https://github.com/oxylabs/playwright-captcha","commit_stats":null,"previous_names":["oxylabs/playwright-captcha"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oxylabs/playwright-captcha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fplaywright-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fplaywright-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fplaywright-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fplaywright-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxylabs","download_url":"https://codeload.github.com/oxylabs/playwright-captcha/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fplaywright-captcha/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30209733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T05:23:27.321Z","status":"ssl_error","status_checked_at":"2026-03-07T05:00:17.256Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["captcha","playwright","playwright-python","scraping-websites"],"created_at":"2025-05-08T21:45:54.648Z","updated_at":"2026-03-07T07:32:44.867Z","avatar_url":"https://github.com/oxylabs.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to Bypass CAPTCHA With Playwright\n\n[![Oxylabs promo code](https://raw.githubusercontent.com/oxylabs/product-integrations/refs/heads/master/Affiliate-Universal-1090x275.png)](https://oxylabs.io/pages/gitoxy?utm_source=877\u0026utm_medium=affiliate\u0026groupid=877\u0026utm_content=playwright-captcha-github\u0026transaction_id=102f49063ab94276ae8f116d224b67)\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\nThis step-by-step tutorial demonstrates how to use Playwright to bypass CAPTCHA challenges using Python. The tutorial will also discuss the perks of using Oxylabs’ Web Unblocker instead of the `playwright-stealth` library. \n\n  * [1. Install dependencies](#1-install-dependencies)\n  * [2. Import modules](#2-import-modules)\n  * [3. Create a headless browser instance](#3-create-a-headless-browser-instance)\n  * [4. Apply the stealth settings](#4-apply-the-stealth-settings)\n  * [6. Take a screenshot](#6-take-a-screenshot)\n  * [7. Execute and test](#7-execute-and-test)\n- [Bypass CAPTCHA with Web Unblocker](#bypass-captcha-with-web-unblocker)\n  * [1. Create an account](#1-create-an-account)\n  * [2. Create API key](#2-create-api-key)\n  * [3. Install the requests module](#3-install-the-requests-module)\n  * [4. Import the required modules](#4-import-the-required-modules)\n  * [6. Make a request](#6-make-a-request)\n  * [7. Save the response](#7-save-the-response)\n  * [8. Execute and check](#8-execute-and-check)\n\n### 1. Install dependencies\nInstall the Playwright library and the stealth package.\n\n```pip install playwright playwright-stealth```\n\n### 2. Import modules \nUse the synchronous version of the Playwright library for a straightforward and linear program flow.\n\n```\nfrom playwright.sync_api import sync_playwright\nfrom playwright_stealth import stealth_sync\n```\n\n### 3. Create a headless browser instance\nDefine the `capture_screenshot()` function that encapsulates the whole code to open a headless browser instance, visit the url, and capture the screenshot. In this function, create a new `sync_playwright` instance and then use it to launch the Chromium browser in headless mode.\n\n```\n# Define the function to capture the screenshot\ndef capture_screenshot():\n    # Create a playwright instance\n    with sync_playwright() as play_wright:\n        browser = play_wright.chromium.launch(headless=True)\n\n        # Create a new context and page\n        context = browser.new_context()\n        page = context.new_page()\n```\n\n### 4. Apply the stealth settings\nAfter creating the browser context, enable Playwright CAPTCHA bypasses by applying the stealth settings to the page using the `playwright-stealth` package. Stealth settings help in reducing the chances of automated access detection by hiding the browsers’ automated behavior.\n\n```\n        # Apply the stealth settings\n        stealth_sync(page)\n```\n\n5. Navigate to the page\nIn the next step, navigate to the target URL by specifying your required URL and navigating to it using the `goto()` page method.\n\n```\n        # Navigate to the website\n        url = \"http://sandbox.oxylabs.io/products\"\n        page.goto(url)\n```\n\n### 6. Take a screenshot\nWait for the page to load completely, take the screenshot, and close the browser.\n\n```\n        # Wait for the webpage to load completely\n        page.wait_for_load_state(\"load\")\n\n        # Take a screenshot\n        screenshot_filename = \"oxylabs_screenshot.png\"\n        page.screenshot(path=screenshot_filename)\n\n        # Close the browser\n        browser.close()\n\n        print(\"Done! You can check the screenshot...\")\n\ncapture_screenshot()\n```\n\n### 7. Execute and test\nHere is what our complete code looks like:\n\n```\n# Import the required modules\nfrom playwright.sync_api import sync_playwright\nfrom playwright_stealth import stealth_sync\n\n# Define the function to capture the screenshot\ndef capture_screenshot():\n    # Create a playwright instance\n    with sync_playwright() as play_wright:\n        browser = play_wright.chromium.launch(headless=True)\n\n        # Create a new context and page\n        context = browser.new_context()\n        page = context.new_page()\n\n        # Apply the stealth settings\n        stealth_sync(page)\n\n        # Navigate to the website\n        url = \"http://sandbox.oxylabs.io/products\"\n        page.goto(url)\n\n        # Wait for the webpage to load completely\n        page.wait_for_load_state(\"load\")\n\n        # Take a screenshot\n        screenshot_filename = \"oxylabs_screenshot.png\"\n        page.screenshot(path=screenshot_filename)\n\n        # Close the browser\n        browser.close()\n\n        print(\"Done! You can check the screenshot...\")\n\ncapture_screenshot()\n```\n\nNote: Executing the code saves the screenshot.\n\n## Bypass CAPTCHA with Web Unblocker\n\nOxylabs’ [Web Unblocker](https://oxylabs.io/products/web-unblocker) employs AI techniques to help you access publicly available information behind the CAPTCHA. You just need to send a simple query and Web Unblocker will automatically choose the fastest CAPTCHA proxy, attach all essential headers, and return the response HTML bypassing any anti-bots of the target websites.\n\n### 1. Create an account\nTo use Web Unblocker, you'll need an active subscription. You can either get a paid plan or a 7-day free trial [here](https://dashboard.oxylabs.io/). \n\n### 2. Create API key\nAfter successfully creating your account, you can set your API key username and password from the dashboard. These API key credentials will be used later in the code.\n\n### 3. Install the requests module\nYou should use a library that can help perform HTTP requests. We will use the `requests` to send HTTP requests to Web  Unblocker API and capture the response.\n\n```pip install requests```\n\n### 4. Import the required modules\nIn your Python script file, import the modules using the following import statement:\n\n```import requests```\n\nCreate the `proxies` dictionary to connect to Web Unblocker and then define the `headers` dictionary that’ll instruct Web Unblocker to use JavaScript rendering. See the [documentation](https://developers.oxylabs.io/advanced-proxy-solutions/web-unblocker) for more details. \n\n```\n# Define proxy dict. Don't forget to pass your Web Unblocker credentials (username and password)\nproxies = {\n   \"http\": \"http://USERNAME:PASSWORD@unblock.oxylabs.io:60000\",\n   \"https\": \"http://USERNAME:PASSWORD@unblock.oxylabs.io:60000\",\n}\n\nheaders = {\n    \"X-Oxylabs-Render\": \"html\"\n}\n```\n\n### 6. Make a request\nPerform your request by specifying the URL, request type, and proxy by using the following code.\n\n```\nresponse = requests.request(\n   \"GET\",\n   \"http://sandbox.oxylabs.io/products\",\n   verify=False,  # Ignore the certificate\n   proxies=proxies,\n)\n```\n\n### 7. Save the response\nWrite the following code to print the response and save it in an HTML file.\n\n```\n# Print result page to stdout\nprint(response.text)\n\n# Save returned HTML to result.html file\nwith open(\"result.html\", \"w\") as f:\n   f.write(response.text)\n```\n\n### 8. Execute and check\nExecute the code and test the output. If the output HTML  file has actual page contents, the script successfully bypassed the CAPTCHA. Here is what our complete code looks like.\n\n```\n# Import the modules\nimport requests\n\n# Define proxy dict. Don't forget to put your real user and pass here as well.\nproxies = {\n   \"http\": \"http://USERNAME:PASSWORD@unblock.oxylabs.io:60000\",\n   \"https\": \"http://USERNAME:PASSWORD@unblock.oxylabs.io:60000\",\n}\n\nheaders = {\n    \"X-Oxylabs-Render\": \"html\"\n}\n\nresponse = requests.request(\n   \"GET\",\n   \"http://sandbox.oxylabs.io/products\",\n   verify=False,  # Ignore the certificate\n   proxies=proxies,\n   headers=headers,\n)\n\n# Print result page to stdout\nprint(response.text)\n\n# Save returned HTML to result.html file\nwith open(\"result.html\", \"w\") as f:\n   f.write(response.text)\n```\n\nAnd that's it! For a more detailed tutorial with images, you can check out this [article](https://oxylabs.io/blog/playwright-bypass-captcha). \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fplaywright-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxylabs%2Fplaywright-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fplaywright-captcha/lists"}