Skip to main content

This package integrates with Selenium or Playwright to solve any Shopee captcha in one line of code.

Project description

Shopee Captcha Solver API

This project is the SadCaptcha Shopee Captcha Solver API client. The purpose is to make integrating SadCaptcha into your Selenium, Playwright, or Async Playwright app as simple as one line of code. Instructions for integrating with Selenium, Playwright, and Async Playwright are described below in their respective sections.

The end goal of this tool is to solve every single Shopee captcha. Currently we are able to solve the crawling image and the puzzle slide:

Shopee Captcha Solver SHopee Captcha Solver

The Crawling Image challenge is the one where there is a puzzle piece that travels in an unpredictable trajectory, and there are two possible locations where the solution may be. This often shows up at login. The puzzle slide is just a simple challenge that asks you to move the piece to the correct location.

Requirements

  • Python >= 3.10
  • If using Selenium - Selenium properly installed and in PATH
  • If using Playwright - Playwright must be properly installed with playwright install
  • Stealth plugin - You must use the appropriate stealth plugin for whichever browser automation framework you are using.

Installation

This project can be installed with pip. Just run the following command:

pip install shopee-captcha-solver

Selenium Client

Import the package, set up the SeleniumSolver class, and call it whenever you need. This turns the entire captcha detection, solution, retry, and verification process into a single line of code. It is the recommended method if you are using Playwright.

from shopee_captcha_solver import SeleniumSolver
from selenium_stealth import stealth
import undetected_chromedriver as uc

driver = uc.Chrome(headless=False) # Use default undetected_chromedriver configuration!
api_key = "YOUR_API_KEY_HERE"
sadcaptcha = SeleniumSolver(driver, api_key)

# Selenium code that causes a Shopee captcha...

sadcaptcha.solve_captcha_if_present(retries=5)

It is crucial that you use undetected_chromedriver with the default configuration, instead of the standard Selenium chromedriver. Failure to use the undetected_chromedriver will result in "Verification failed" when attempting to solve the captcha.

Playwright Client

Import the package, set up the PlaywrightSolver class, and call it whenever you need. This turns the entire captcha detection, solution, retry, and verification process into a single line of code. It is the recommended method if you are using playwright.

from shopee_captcha_solver import PlaywrightSolver
from playwright.sync_api import Page, sync_playwright
from playwright_stealth import stealth_sync, StealthConfig

api_key = "YOUR_API_KEY_HERE"

with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()
    config = StealthConfig(navigator_languages=False, navigator_vendor=False, navigator_user_agent=False)
    stealth_sync(page, config) # Use correct playwright_stealth configuration!
    
    # Playwright code that causes a Shopee captcha...

    sadcaptcha = PlaywrightSolver(page, api_key)
    sadcaptcha.solve_captcha_if_present(retries=5)

It is crucial that users of the Playwright client also use playwright-stealth with the configuration specified above. Failure to use the playwright-stealth plugin will result in "Verification failed" when attempting to solve the captcha.

Async Playwright Client

Import the package, set up the AsyncPlaywrightSolver class, and call it whenever you need. This turns the entire captcha detection, solution, retry, and verification process into a single line of code. It is the recommended method if you are using async playwright.

import asyncio
from shopee_captcha_solver import AsyncPlaywrightSolver
from playwright.async_api import Page, async_playwright
from playwright_stealth import stealth_async, StealthConfig

api_key = "YOUR_API_KEY_HERE"

async def main()
    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=False)
        page = await browser.new_page()
        config = StealthConfig(navigator_languages=False, navigator_vendor=False, navigator_user_agent=False)
        await stealth_async(page, config) # Use correct playwright_stealth configuration!
        
        # Playwright code that causes a Shopee captcha...

        sadcaptcha = AsyncPlaywrightSolver(page, api_key)
        await sadcaptcha.solve_captcha_if_present(retries=5)

asyncio.run(main())

It is crucial that users of the Playwright client also use playwright-stealth with the stealth configuration specified above. Failure to use the playwright-stealth plugin will result in "Verification failed" when attempting to solve the captcha.

Using Proxies and Custom Headers

SadCaptcha supports using proxies and custom headers such as user agent. This is useful to avoid detection. To implement this feature, pass your proxy URL and headers dictionary as a keyword argument to the constructor of the solver.

api_key = "YOUR_API_KEY_HERE"
proxy = "http://username:password@123.0.1.2:80"
headers = {"User-Agent": "Chrome"}

# With Selenium Solver
driver = uc.Chrome(headless=False) # Use default undetected_chromedriver configuration!
api_key = "YOUR_API_KEY_HERE"
sadcaptcha = SeleniumSolver(driver, api_key, proxy=proxy, headers=headers)

# With Playwright Solver
with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()
    stealth_sync(page) # Use default playwright_stealth configuration!
    sadcaptcha = PlaywrightSolver(page, api_key, proxy=proxy, headers=headers)
    sadcaptcha.solve_captcha_if_present(retries=5)

# With Async PlaywrightSolver
async def main()
    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=False)
        page = await browser.new_page()
        await stealth_async(page) # Use default playwright_stealth configuration!
        sadcaptcha = AsyncPlaywrightSolver(page, api_key, headers=headers, proxy=proxy)
        await sadcaptcha.solve_captcha_if_present(retries=5)

Contact

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shopee_captcha_solver-0.1.2.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

shopee_captcha_solver-0.1.2-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file shopee_captcha_solver-0.1.2.tar.gz.

File metadata

  • Download URL: shopee_captcha_solver-0.1.2.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for shopee_captcha_solver-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2b90708ed11b348ef686849d25fb3694c90e33e063af07071f7338cc2f5d1fa0
MD5 6aed2451d648b510ccfca21d2b2eb2a8
BLAKE2b-256 a98c11c0ef25be5f3e959f0a20755bacd655f0f7e8a079c8098d785fa6141f65

See more details on using hashes here.

File details

Details for the file shopee_captcha_solver-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for shopee_captcha_solver-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e864bd43dc310bf5f74aaaccfdccbe91ed23a8abe98b70528d85a93b9e3c5ea3
MD5 217b04e53326d1e80f8d1d7ad969b673
BLAKE2b-256 743fcea4fba64ddad2448dc1e34a0749fd289a1dfb16af465dd3fb96108d2f7e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page