Giter Site home page Giter Site logo

anti_captcha's Introduction

Developed by Infosimples.

AntiCaptcha

AntiCaptcha is a Ruby API for Anti-Captcha - Anti-Captcha.com.

Installation

Add this line to your application's Gemfile:

gem 'anti_captcha'

And then execute:

$ bundle

Or install it yourself as:

$ gem install anti_captcha

Usage

  1. Create a client
# Create a client
client = AntiCaptcha.new('my_key')
  1. Solve Image CAPTCHA

There are two methods available:

  • decode_image: solves image CAPTCHAs. It doesn't raise exceptions.
  • decode_image!: solves image CAPTCHAs. It may raise an AntiCaptcha::Error if something goes wrong.

If the solution is not available, an empty solution object will be returned.

solution = client.decode_image!(path: 'path/to/my/captcha/file')
solution.text                # CAPTCHA solution.
solution.url                 # Image URL.
solution.task_result.task_id # The ID of the task.

You can also specify file, body and body64 when decoding an image.

client.decode_image!(file: File.open('path/to/my/captcha/file', 'rb'))

client.decode_image!(body: File.open('path/to/my/captcha/file', 'rb').read)

client.decode_image!(body64: Base64.encode64(File.open('path/to/my/captcha/file', 'rb').read))

Internally, the gem will always convert the image to body64 (binary base64 encoded).

  1. Report incorrectly solved image CAPTCHA for refund

It is only possible to report incorrectly solved image CAPTCHAs.

client.report_incorrect_image_catpcha!(task_id)
  1. Get your account balance
client.get_balance!
  1. Get current stats of a queue.

Queue IDs:

  • 1 Standart ImageToText, English language.
  • 2 Standart ImageToText, Russian language.
  • 5 Recaptcha NoCaptcha tasks.
  • 6 Recaptcha Proxyless task.
client.get_queue_stats!(queue_id)
  1. Clickable CAPTCHAs (e.g. "No CAPTCHA reCAPTCHA")

This method allows you to solve CAPTCHAs similar to reCAPTCHA v2.

There are two methods available:

  • decode_nocaptcha: solves NoCaptcha CAPTCHAs. It doesn't raise exceptions.
  • decode_nocaptcha!: solves NoCaptcha CAPTCHAs. It may raise an AntiCaptcha::Error if something goes wrong.

Send the website_key and website_url parameters

This method requires no browser emulation. You can send two parameters that identify the website in which the CAPTCHA is found.

options = {
  website_key: 'xyz',
  website_url: 'http://example.com/example=1'
}

solution = client.decode_nocaptcha!(options)
solution.g_recaptcha_response # Solution of the captcha

The solution (solution.g_recaptcha_response) will be a code that validates the form, like the following:

"1JJHJ_VuuHAqJKxcaasbTsqw-L1Sm4gD57PTeaEr9-MaETG1vfu2H5zlcwkjsRoZoHxx6V9yUDw8Ig-hYD8kakmSnnjNQd50w_Y_tI3aDLp-s_7ZmhH6pcaoWWsid5hdtMXyvrP9DscDuCLBf7etLle8caPWSaYCpAq9DOTtj5NpSg6-OeCJdGdkjsakFUMeGeqmje87wSajcjmdjl_w4XZBY2zy8fUH6XoAGZ6AeCTulIljBQDObQynKDd-rutPvKNxZasDk-LbhTfw508g1lu9io6jnvm3kbAdnkfZ0x0PkGiUMHU7hnuoW6bXo2Yn_Zt5tDWL7N7wFtY6B0k7cTy73f8er508zReOuoyz2NqL8smDCmcJu05ajkPGt20qzpURMwHaw"
  1. FunCaptcha

This method allows you to solve FunCaptcha.

Send the website_public_key and website_url parameters

This method requires no browser emulation. You can send two parameters that identify the website in which the CAPTCHA is found.

options = {
  website_public_key: 'xyz',
  website_url: 'http://example.com/example=1',
  language_pool: '...'
}

solution = client.decode_fun_captcha(options)
solution.token # Solution of the captcha
  1. reCAPTCHA V3

This method allows you to solve reCAPTCHA v3.

There are two methods available:

  • decode_recaptcha_v3: solves reCAPTCHA v3. It doesn't raise exceptions.
  • decode_recaptcha_v3!: solves reCAPTCHA v3. It may raise an AntiCaptcha::Error if something goes wrong.

Send the website_key, website_url, min_score and page_action parameters

This method requires no browser emulation. You can send four parameters that identify the website in which the CAPTCHA is found and the minimum score (0.3, 0.5 or 0.7) you desire.

It's strongly recommended to use a minimum score of 0.3 as higher scores are extremely rare.

options = {
  website_key: 'xyz',
  website_url: 'http://example.com/example=1',
  min_score:   0.3,
  page_action: 'myverify'
}

solution = client.decode_recaptcha_v3!(options)
solution.g_recaptcha_response # Solution of the captcha

The solution (solution.g_recaptcha_response) will be a code that validates the form, like the following:

"1JJHJ_VuuHAqJKxcaasbTsqw-L1Sm4gD57PTeaEr9-MaETG1vfu2H5zlcwkjsRoZoHxx6V9yUDw8Ig-hYD8kakmSnnjNQd50w_Y_tI3aDLp-s_7ZmhH6pcaoWWsid5hdtMXyvrP9DscDuCLBf7etLle8caPWSaYCpAq9DOTtj5NpSg6-OeCJdGdkjsakFUMeGeqmje87wSajcjmdjl_w4XZBY2zy8fUH6XoAGZ6AeCTulIljBQDObQynKDd-rutPvKNxZasDk-LbhTfw508g1lu9io6jnvm3kbAdnkfZ0x0PkGiUMHU7hnuoW6bXo2Yn_Zt5tDWL7N7wFtY6B0k7cTy73f8er508zReOuoyz2NqL8smDCmcJu05ajkPGt20qzpURMwHaw"

Notes

Ruby dependencies

AntiCaptcha doesn't require specific dependencies. That saves you memory and avoid conflicts with other gems.

Input image format

Any format you use in the decode method (file, path, body, body64) will always be converted to a body64, which is a binary base64 encoded string. So, if you already have this format available on your side, there's no need to do convertions before calling the API.

Our recomendation is to never convert your image format, unless needed. Let the gem convert internally. It may save you resources (CPU, memory and IO).

Versioning

AntiCaptcha gem uses Semantic Versioning.

License

MIT License. Copyright (C) 2011-2015 Infosimples. https://infosimples.com/

anti_captcha's People

Contributors

rafaelivan avatar

Watchers

 avatar

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.