Git Product home page Git Product logo

recognizer's Introduction

reCognizer v1.4

Tests & Linting Downloads

reCognizer is a free-to-use AI based reCaptcha Solver.
Usable with an easy-to-use API, also available for Async and Sync Playwright.
You can pass almost any format into the Challenger, from full-page screenshots, only-captcha images and no-border images to single images in a list.

Note: You Should use an undetected browser engine like Botright to solve the Captchas consistently.
reCaptcha detects normal Playwright easily and you probably wont get any successful solves despite correct recognitions.


Sponsors

Capsolver Banner

Capsolver.com is an AI-powered service that specializes in solving various types of captchas automatically. It supports captchas such as reCAPTCHA V2, reCAPTCHA V3, hCaptcha, FunCaptcha, DataDome, AWS Captcha, Geetest, and Cloudflare Captcha / Challenge 5s, Imperva / Incapsula, among others.

For developers, Capsolver offers API integration options detailed in their documentation, facilitating the integration of captcha solving into applications. They also provide browser extensions for Chrome and Firefox, making it easy to use their service directly within a browser. Different pricing packages are available to accommodate varying needs, ensuring flexibility for users.


Install it from PyPI

pip install recognizer

Examples

Possible Image Inputs

Accepted Formats

Example Solve Video (Good IP & Botright)

reCognizer.mp4

Basic Usage

# Only for Type-Hints
from typing import TypeVar, Sequence, Union
from pathlib import Path
from os import PathLike

accepted_image_types = TypeVar("accepted_image_types", Path, Union[PathLike[str], str], bytes, Sequence[Path], Sequence[Union[PathLike[str], str]], Sequence[bytes])

# Real Code
from recognizer import Detector

detector = Detector()

task_type: str = "bicycle"
images: accepted_image_types = "recaptcha_image.png"
area_captcha: bool = False

response, coordinates = detector.detect(task_type, images, area_captcha=area_captcha)

Playwright Usage

Sync Playwright

from playwright.sync_api import sync_playwright, Playwright
from recognizer.agents.playwright import SyncChallenger


def run(playwright: Playwright):
    browser = playwright.chromium.launch()
    page = browser.new_page()

    challenger = SyncChallenger(page)
    page.goto("https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox-explicit.php")

    challenger.solve_recaptcha()

    browser.close()


with sync_playwright() as playwright:
    run(playwright)

Async Playwright

import asyncio

from playwright.async_api import async_playwright, Playwright
from recognizer.agents.playwright import AsyncChallenger


async def run(playwright: Playwright):
    browser = await playwright.chromium.launch()
    page = await browser.new_page()

    challenger = AsyncChallenger(page)
    await page.goto("https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox-explicit.php")

    await challenger.solve_recaptcha()

    await browser.close()


async def main():
    async with async_playwright() as playwright:
        await run(playwright)


asyncio.run(main())

Copyright and License

© Vinyzu

GNU GPL

(Commercial Usage is allowed, but source, license and copyright has to made available. reCaptcha Challenger does not provide and Liability or Warranty)


Thanks to

QIN2DIM (For basic project structure)


Version License Python

my-discord buy-me-a-coffee

recognizer's People

Contributors

dependabot[bot] avatar vinyzu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

recognizer's Issues

[BUG] Too many errors reported, unable to run

Describe the bug
My Python version is 3.9. Since you didn't mention your version, I assumed all versions were compatible, but encountered many errors.
error 1 :

 File "/usr/local/lib/python3.9/dist-packages/transformers/utils/import_utils.py", line 1510, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/local/lib/python3.9/dist-packages/transformers/models/vit/image_processing_vit.py", line 21, in <module>
    from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
ImportError: cannot import name 'BaseImageProcessor' from partially initialized module 'transformers.image_processing_utils' (most likely due to a circular import) (/usr/local/lib/python3.9/dist-packages/transformers/image_processing_utils.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/recaptcha_solver_test/main.py", line 81, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/root/recaptcha_solver_test/main.py", line 78, in main
    await run(playwright,"free.vps.vc","6Lf6qrMjAAAAAK3VbiN3PkzoXux6p3kEVDmBJA5p")
  File "/root/recaptcha_solver_test/main.py", line 71, in run
    await challenger.solve_recaptcha()
  File "/usr/local/lib/python3.9/dist-packages/recognizer/agents/playwright/async_control.py", line 204, in solve_recaptcha
    return await self.handle_recaptcha()
  File "/usr/local/lib/python3.9/dist-packages/recognizer/agents/playwright/async_control.py", line 149, in handle_recaptcha
    result_clicked = await self.detect_tiles(prompt, area_captcha)
  File "/usr/local/lib/python3.9/dist-packages/recognizer/agents/playwright/async_control.py", line 83, in detect_tiles
    response, coordinates = self.detector.detect(prompt, image, area_captcha=area_captcha)
  File "/usr/local/lib/python3.9/dist-packages/recognizer/components/detector.py", line 288, in detect
    detection_models.check_loaded()
  File "/usr/local/lib/python3.9/dist-packages/recognizer/components/detector.py", line 76, in check_loaded
    raise e
  File "/usr/local/lib/python3.9/dist-packages/recognizer/components/detector.py", line 66, in check_loaded
    future.result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 433, in result
    return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.9/dist-packages/recognizer/components/detector.py", line 60, in _load_seg_processor
    self.seg_processor = CLIPSegProcessor.from_pretrained("CIDAS/clipseg-rd64-refined")
  File "/usr/local/lib/python3.9/dist-packages/transformers/processing_utils.py", line 465, in from_pretrained
    args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/transformers/processing_utils.py", line 509, in _get_arguments_from_pretrained
    attribute_class = getattr(transformers_module, class_name)
  File "/usr/local/lib/python3.9/dist-packages/transformers/utils/import_utils.py", line 1501, in __getattr__
    value = getattr(module, name)
  File "/usr/local/lib/python3.9/dist-packages/transformers/utils/import_utils.py", line 1500, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "/usr/local/lib/python3.9/dist-packages/transformers/utils/import_utils.py", line 1512, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.models.vit.image_processing_vit because of the following error (look up to see its traceback):
cannot import name 'BaseImageProcessor' from partially initialized module 'transformers.image_processing_utils' (most likely due to a circular import) (/usr/local/lib/python3.9/dist-packages/transformers/image_processing_utils.py)

error 2:

File "/root/recaptcha_solver_test/main.py", line 71, in run
    await challenger.solve_recaptcha()
  File "/usr/local/lib/python3.9/dist-packages/recognizer/agents/playwright/async_control.py", line 204, in solve_recaptcha
    return await self.handle_recaptcha()
  File "/usr/local/lib/python3.9/dist-packages/recognizer/agents/playwright/async_control.py", line 149, in handle_recaptcha
    result_clicked = await self.detect_tiles(prompt, area_captcha)
  File "/usr/local/lib/python3.9/dist-packages/recognizer/agents/playwright/async_control.py", line 83, in detect_tiles
    response, coordinates = self.detector.detect(prompt, image, area_captcha=area_captcha)
  File "/usr/local/lib/python3.9/dist-packages/recognizer/components/detector.py", line 342, in detect
    response = self.clip_detector.detect_image(cv2_images, label)
  File "/usr/local/lib/python3.9/dist-packages/recognizer/components/detector.py", line 237, in detect_image
    return self.clipseg_detect_rd64(combined_image, task_type, len(images))
  File "/usr/local/lib/python3.9/dist-packages/recognizer/components/detector.py", line 200, in clipseg_detect_rd64
    inputs = detection_models.seg_processor(text=segment_label, images=[image], return_tensors="pt")
AttributeError: 'DetectionModels' object has no attribute 'seg_processor'

error 3:

huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
To disable this warning, you can either:
        - Avoid using `tokenizers` before the fork if possible
        - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
To disable this warning, you can either:
        - Avoid using `tokenizers` before the fork if possible
        - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
To disable this warning, you can either:
        - Avoid using `tokenizers` before the fork if possible
        - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)

Desktop (please complete the following information):

  • OS: Debian
  • Version 11

[FEATURE] API Mode

Is your feature request related to a problem? Please describe.
It isn't a problem but rather a featzre request.

Describe the solution you'd like
The possibility to input a sitekey + url to then solve recaptcha v2.

Describe alternatives you've considered
Using something like CapSolver, but that is paid, so a free solution could be better.

Additional context
No images, description should be enough.

Handle case were recaptcha v2 got solved by one click

Is your feature request related to a problem? Please describe.
Sometimes a recaptcha v2 doesn't asks us to click on images, i think the score is so nice sometimes that just a click is enough.
But so, i got this log error: An error occured: [ERROR] reCaptcha Challenge is not visible.

Describe the solution you'd like
I would like the code to verify if the challenge has already been solved, maybe verifying trhough routes?

PS: if you do not have time to, i can dig into your code and make a merge request

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.