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 Nodriver - Google chrome installed on system. This is the recommended method.
  • If using Selenium - Selenium properly installed and in PATH
  • If using Playwright - Playwright must be properly installed with playwright install
  • Stealth plugin - You should 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

Nodriver Client (Recommended)

Nodriver is the latest advancement in undetected automation technology, and is the recommended method for using SadCaptcha. Import the function make_nodriver_solver This function will create an noddriver instance patched with the Shopee Captcha Solver chrome extension. The extension will automatically detect and solve the captcha in the background, and there is nothing further you need to do.

from shopee_captcha_solver.launcher import make_nodriver_solver

async def main():
    launch_args = ["--headless=chrome"] # If running headless, use this option, or headless=new
    api_key = "YOUR_API_KEY_HERE"
    # NOTE: Keyword arguments passed to make_nodriver_solver() are directly passed to nodriver.start()!
    driver = await make_nodriver_solver(api_key, browser_args=launch_args) # Returns nodriver browser 
    # ... [The rest of your code that accesses shopee goes here]
    # Now shopee captchas will be automatically solved!

All keyword arguments passed to make_nodriver_solver() are passed directly to nodriver.start().

Selenium Client

Import the function make_undetected_chromedriver_solver. This function will create an undetected chromedriver instance patched with the Shopee Captcha Solver chrome extension. The extension will automatically detect and solve the captcha in the background, and there is nothing further you need to do.

from shopee_captcha_solver import make_undetected_chromedriver_solver
from selenium_stealth import stealth
from selenium.webdriver import ChromeOptions
import undetected_chromedriver as uc

chrome_options = ChromeOptions()
# chrome_options.add_argument("--headless=chrome") # If running headless, use this option

api_key = "YOUR_API_KEY_HERE"
driver = make_undetected_chromedriver_solver(api_key, options=options) # Returns uc.Chrome instance
stealth(driver) # Add stealth if needed
# ... [The rest of your code that accesses shopee goes here]

# Now shopee captchas will be automatically solved!

You may also pass ChromeOptions to make_undetected_chromedriver_solver(), as well as keyword arguments for uc.Chrome().

Playwright Client

Import the function make_playwright_solver_context. This function will create a playwright BrowserContext instance patched with the Shopee Captcha Solver chrome extension. The extension will automatically detect and solve the captcha in the background, and there is nothing further you need to do.

from shopee_captcha_solver import make_playwright_solver_context
from playwright.sync_api import sync_playwright

# Need this arg if running headless
launch_args = ["--headless=chrome"] 

api_key = "YOUR_API_KEY_HERE"
with sync_playwright() as p:
    context = make_playwright_solver_context(p, api_key, args=launch_args) # Returns playwright BrowserContext instance
    # ... [The rest of your code that accesses shopee goes here]

# Now shopee captchas will be automatically solved!

You may also pass keyword args to this function, which will be passed directly to playwright's call to playwright.chromium.launch_persistent_context(). By default, the user data directory is a tempory directory that is deleted at the end of runtime.

Async Playwright Client

Import the function make_async_playwright_solver_context. This function will create an async playwright BrowserContext instance patched with the Shopee Captcha Solver chrome extension. The extension will automatically detect and solve the captcha in the background, and there is nothing further you need to do.

import asyncio
from playwright.async_api import async_playwright
from shopee_captcha_solver import make_async_playwright_solver_context

# Need this arg if running headless
launch_args = ["--headless=chrome"] 

async def main():
    api_key = "YOUR_API_KEY_HERE"
    async with async_playwright() as p:
        context = await make_async_playwright_solver_context(p, api_key, args=launch_args) # Returns playwright BrowserContext instance
        # ... [The rest of your code that accesses shopee goes here]

asyncio.run(main())

# Now shopee captchas will be automatically solved!

You may also pass keyword args to this function, which will be passed directly to playwright's call to playwright.chromium.launch_persistent_context(). By default, the user data directory is a tempory directory that is deleted at the end of runtime.

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.2.1.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shopee_captcha_solver-0.2.1-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: shopee_captcha_solver-0.2.1.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for shopee_captcha_solver-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2cf42550335eaa325bd0f1ac30d1063476ba3fb16cc55b6d2622061c3d18754a
MD5 690b90f3eeb011bc7b79dd3ec1896878
BLAKE2b-256 e0d9740f7ed7a7182b82d0929b72f46420067a0cd477088e7f726a22ce5d790b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for shopee_captcha_solver-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 97085ebaab6413e4c041238d7f24efc95e9423520f2422015f22850c11568390
MD5 2dfddbeced46a8178f9bdc0a863da511
BLAKE2b-256 80adb474f73150b077a5a3aa5ea24ee14b48cb1aaa87e9cee6c4e486422e7629

See more details on using hashes here.

Supported by

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