For those who use headless browsers or just can't/doesn't want to install our extension we've developed an includible JS file which solves a captcha. It works only for a Recaptcha at the moment, image captchas are not supported.
This includible JS file also good for iMacros application, the only difference is that it should be connected otherwise, you can see an example on the reCAPTCHA 2 solving in iMacros application web-page.
Before we use a main code that solves a Recaptcha we need to set our AntiCaptcha API key which is placed into a DIV element using the following code:
This extension will simply click on the 'I'm not robot' checkbox as soon as the page loads. It won't click twice within 7 seconds however. If the popup box appears too often after a circle then it means your IP address/network seems to be spammy to Google. Pay-per-captcha payment basis. Minimum refill is 1 USD, no recurring charges. 99.99% uptime since 2007. Vast amount of workers and premium infrastructure allows us to provide highly reliable 24/7/365 service. Solving Google Recaptcha since 2016.
(function(){ // .. var d = document.getElementById('anticaptcha-imacros-account-key'); if (!d) { d = document.createElement('div'); d.innerHTML = 'YOUR-ANTI-CAPTCHA-API-KEY'; d.style.display = 'none'; d.id = 'anticaptcha-imacros-account-key'; document.body.appendChild(d); } // .. })();
You only need to replace YOUR-ANTI-CAPTCHA-API-KEY with your key.
Nothing special here. We just created an invisible element with id=anticaptcha-imacros-account-key/download-game-naruto-storm-4-mugen-2017.html. and placed an API key inside of it and then put this element into the target web-page. This API key will be used by the main JS code.
This piece of code can be run in any environment. For instance in a browser console (F12) or in another includible JS file or using any other extension e.g. TamperMonkey or Greasemonkey.
Now it time to connect a script itself which does all the job:
(function(){ // .. var s = document.createElement('script'); s.src = 'https://cdn.antcpt.com/imacros_inclusion/recaptcha.js?' + Math.random(); document.body.appendChild(s); // .. })();
This piece of code creates a SCRIPT element with a src=https://cdn.antcpt.com/imacros_inclusion/recaptcha.js and appends it into DOM. It's always recommended to connect this JS file from our web-server to have a latest version of this script with all the fixes and new features.
As a result, we have the following script:
(function(){ // .. var d = document.getElementById('anticaptcha-imacros-account-key'); if (!d) { d = document.createElement('div'); d.innerHTML = 'YOUR-ANTI-CAPTCHA-API-KEY'; d.style.display = 'none'; d.id = 'anticaptcha-imacros-account-key'; document.body.appendChild(d); } var s = document.createElement('script'); s.src = 'https://cdn.antcpt.com/imacros_inclusion/recaptcha.js?' + Math.random(); document.body.appendChild(s); // .. })();
On certain websites it's forbidden to include any external JS file because of a Content-Security-Policy header and our recaptcha.js won't be embedded as well.
In such cases a whole code of a JS recaptcha solving file can be placed by one line. Instead of creating a SCRIPT element you just put into your script a content of the following file
https://cdn.antcpt.com/imacros_inclusion/recaptcha.ai-sl.js .
All the code that solves a captcha and modules are compiled into a big big single line. It's not convenient, ugly and not recommended to do. But somethimes there is simply no other way.
Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. It can sound scary, but in fact the Puppeteer is a good tool for headless Chrome automatisation, it allows you to do many thing with different ways. See documentation for installation guide and usage examples.
Code snippet below tells browser to go to the web-page with reCAPTCHA 2 demo form, solves the Recaptcha and sends a web-form. Further it makes a screen shot for clarity. For the Recaptcha solving it creates an DIV where your AntiCaptcha API should be placed and then it includes the https://cdn.antcpt.com/imacros_inclusion/recaptcha.js file, the same as in other examples.
const puppeteer = require('puppeteer'); puppeteer.launch().then(async (browser) => { const page = await browser.newPage(); // set a screen size page.setViewport({ width: 1024, height: 768 }); // watch debug info from anti-captcha solver page.on('console', msg => { for (let i = 0; i < msg.args().length; ++i) { console.log(`${i}: ${msg.args()[i]}`); } }); page.once('load', async () => { // Fetch Anti-Captcha API key in DIV#anticaptcha-imacros-account-key element await page.evaluate(() => { var antcptAccountKeyDiv = document.getElementById('anticaptcha-imacros-account-key'); if (!antcptAccountKeyDiv) { antcptAccountKeyDiv = document.createElement('div'); // put your API key here antcptAccountKeyDiv.innerHTML = 'YOUR-ANTI-CAPTCHA-API-KEY'; antcptAccountKeyDiv.style.display = 'none'; antcptAccountKeyDiv.id = 'anticaptcha-imacros-account-key'; document.body.appendChild(antcptAccountKeyDiv); } }); // anticaptchaUserCallbackMethod will be called (if defined) when something changes // captchaSolvingInfo contains 'status' field of a captcha solving process, // which might be: in_process, error, solved await page.exposeFunction('anticaptchaUserCallbackMethod', (captchaSolvingInfo) => { console.log('captchaSolvingInfo', captchaSolvingInfo); }); // Include recaptcha.js file with all the functional await page.addScriptTag({ url: 'https://cdn.antcpt.com/imacros_inclusion/recaptcha.js'}); // Fill the text field with test value await page.$eval('input[name=demo_text]', el => el.value = 'Test message'); // Most important part: we wait 120 seconds until an AntiCatcha indicator // with class 'antigate_solver' gets in additional 'solved' class await page.waitForSelector('.antigate_solver.solved', { timeout: 120 * 1000 }); // Send form and waiting for page being loaded const navigationPromise = page.waitForNavigation(); page.click(['input[type=submit]']); await navigationPromise; // check if we did it right await page.screenshot({ path: 'screenshot_solved.png' }); // closing browser await browser.close(); }); // Go to the test web-page await page.goto('https://antcpt.com/eng/information/demo-form/recaptcha-2.html'); });
Latest versionReleased:
Client library for solve captchas with Anticaptcha.com support.
Client library for solve captchas with Anticaptcha.com support.The library supports both Python 2.7 and Python 3.
The library is cyclically and automatically tested for proper operation. We are constantly making the best efforts for its effective operation.
In case of any problems with integration - read the documentation, create an issue, use Gitter or contact privately.
Install as standard Python package using:
To use this library do you need Anticaptcha.com API key.
Example snippet for Recaptcha:
The full integration example is available in file examples/recaptcha.py.
If you only process few page many times to increase reliability, you can specifywhether the captcha is visible or not. This parameter is not required, as is thesystem detects invisible sitekeys automatically, and needs several recursivemeasures for automated training and analysis. For provide that passis_invisible parameter to NoCaptchaTaskProxylessTask or NoCaptchaTask eg.:
Example snippet for text captcha:
Example snippet for reporting an incorrect image task:
There is support for your own (captcha) forms. It allows you to analyze any data in various ways, eg. classify offensiveimage, count elements on the image, etc. The scope of the data, the form to describe them, you specify yourself.
For details, go to ‘Custom fields’ section in the documentation.
The library is not responsible for managing the proxy server. However, we point tothe possibility of simply launching such a server by:
Next to in your application use something like:
We recommend entering IP-based access control for incoming addresses to proxy. IP address required byAnticaptcha.com is:
In the event of an application error, the AnticaptchaException exception is thrown. To handle the exception, do the following:
We use SemVer for versioning. For the versions available, see thetags on this repository.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.mdfile for details
0.7.1
0.7.0
Mi pc suite for mac free download. 0.6.0
0.5.1
0.5.0
0.4.2
0.4.1
0.4.0
0.3.1
0.3.0
0.1.1
0.1.0
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.1
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size python_anticaptcha-0.7.1-py2.py3-none-any.whl (10.7 kB) | File type Wheel | Python version py2.py3 | Upload date | Hashes |
Filename, size python-anticaptcha-0.7.1.tar.gz (434.6 kB) | File type Source | Python version None | Upload date | Hashes |
Algorithm | Hash digest |
---|---|
SHA256 | f719fa76cdb0597ca6ff377540b999a1ecc77ce4e04c10f7e286d8dd8d189cc6 |
MD5 | 5f5d7250c2bf368e0064caac20215125 |
BLAKE2-256 | 1267bb6a4642a7e886c10774e28428c5f9b33061f4a0c2b6738cd6ba7a3ba7ab |
Algorithm | Hash digest |
---|---|
SHA256 | 6d13df6702222b7adac29872f826079a72008177e95b4095a33d66b1050e8d86 |
MD5 | c4392af97a5b677b9264375ec383460d |
BLAKE2-256 | 8cd9a112e1c4a422d87037a8773d976e9c2811075cc66a8faf3c7f510511fb12 |