Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Current »

At the moment the following language examples are available:


 PHP example

Download : Git Repository
Google No-Captcha solving example
include("anticaptcha.php");
include("nocaptchaproxyless.php");

$api = new NoCaptchaProxyless();
$api->setVerboseMode(true);
        
//your anti-captcha.com account key
$api->setKey("API_KEY_HERE");

//target website address
$api->setWebsiteURL("http://makeawebsitehub.com/recaptcha/test.php");

//recaptcha key from target website
$api->setWebsiteKey("6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ");

//create task in API
if (!$api->createTask()) {
    $api->debout("API v2 send failed - ".$api->getErrorMessage(), "red");
    return false;
}

$taskId = $api->getTaskId();

//wait in a loop for max 300 seconds till task is solved
if (!$api->waitForResult(300)) {
    echo "could not solve captcha\n";
    echo $api->getErrorMessage()."\n";
} else {
    
    $gResponse    =   $api->getTaskSolution();
    echo "\nyour recaptcha token: $gResponse\n\n";
    
}

 NodeJS example

Download: Git Repository
Anti-Captcha NodeJS example
// http module should be installed:
// npm i http

// Params:
// your anti-captcha.com account key
var anticaptcha = require('./anticaptcha')('YOUR_API_KEY');

//recaptcha key from target website
anticaptcha.setWebsiteURL("http://makeawebsitehub.com/recaptcha/test.php");
anticaptcha.setWebsiteKey("6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ");

anticaptcha.createTaskProxyless(function (err, taskId) {
        if (err) {
            console.error(err);
            return;
        }

        console.log('Got task ID', taskId);

        //wait for solution and print to console
        anticaptcha.getTaskSolution(taskId, function (err, taskSolution) {
            if (err) {
                console.error(err);
                return;
            }
            
            console.log(taskSolution);
        });
    }
);

 JAVA example

Download : Git Repository
package com.anti_captcha;

import com.anti_captcha.Api.NoCaptchaProxyless;
import com.anti_captcha.Helper.DebugHelper;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.concurrent.ThreadLocalRandom;

public class Main {

    public static void main(String[] args) throws InterruptedException, MalformedURLException, JSONException {

        DebugHelper.setVerboseMode(true);

        NoCaptchaProxyless api = new NoCaptchaProxyless();
        api.setClientKey("API_KEY_HERE");
        api.setWebsiteUrl(new URL("http://makeawebsitehub.com/recaptcha/test.php"));
        api.setWebsiteKey("6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ");

        if (!api.createTask()) {
            DebugHelper.out(
                    "API v2 send failed. " + api.getErrorMessage(),
                    DebugHelper.Type.ERROR
            );
        } else if (!api.waitForResult()) {
            DebugHelper.out("Could not solve the captcha.", DebugHelper.Type.ERROR);
        } else {
            DebugHelper.out("Result: " + api.getTaskSolution().getGRecaptchaResponse(), DebugHelper.Type.SUCCESS);
        }
    }
}

 C# example

Download: Git repository
using System;
using Anticaptcha_example.Api;
using Anticaptcha_example.Helper;
using Newtonsoft.Json.Linq;

namespace Anticaptcha_example
{
    internal class Program
    {
        private static void Main() {
            DebugHelper.VerboseMode = true;
            var api = new NoCaptchaProxyless
            {
                ClientKey = "YOUR_API_KEY",
                WebsiteUrl = new Uri("http://makeawebsitehub.com/recaptcha/test.php"),
                WebsiteKey = "6LfI9IsUAAAAAKuvopU0hfY8pWADfR_mogXokIIZ"
            };
            
            if (!api.CreateTask())
                DebugHelper.Out("API v2 send failed. " + api.ErrorMessage, DebugHelper.Type.Error);
            else if (!api.WaitForResult())
                DebugHelper.Out("Could not solve the captcha.", DebugHelper.Type.Error);
            else
                DebugHelper.Out("Result: " + api.GetTaskSolution().GRecaptchaResponse, DebugHelper.Type.Success);
                
        }
    }
}

  • No labels