Page tree
Skip to end of metadata
Go to start of metadata

Download : Git Repository

import java.io.IOException;

public class Main {

    private static String host = "api.anti-captcha.com";
    private static String clientKey = "12345678901234567890123456789012";

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

        AnticaptchaTask task1 = AnticaptchaApiWrapper.createNoCaptchaTask(
                host,
                clientKey,
                "http://http.myjino.ru/recaptcha/test-get.php",	//target website
                "6Lc_aCMTAAAAABx7u2W0WPXnVbI_v6ZdbM6rYf16",		//target website Recaptcha key
                AnticaptchaApiWrapper.ProxyType.http,
                "xx.xx.xx.xxx",									//ipv4 or ipv6 proxy address
                8080,											//proxy port
                "login",										//proxy login
                "password",										//proxy password
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36"
        );

        System.out.println("NoCaptcha task is sent, will wait for the result.");
        Thread.sleep(10_000);
        processTask(task1);


        // Exit
        System.in.read();
    }

    private static String processTask(AnticaptchaTask task) throws InterruptedException {

        AnticaptchaResult response;

        do
        {
            response = AnticaptchaApiWrapper.getTaskResult(host, clientKey, task);

            if (response.getStatus().equals(AnticaptchaResult.Status.ready))
            {
                break;
            }

            System.out.println("Not done yet, waiting...");
            Thread.sleep(1000);
        } while (response != null && response.getStatus().equals(AnticaptchaResult.Status.processing));

        if (response == null || response.getSolution() == null) {
            System.out.println("Unknown error occurred...");
            System.out.println("Response dump:");
            System.out.println(response);
        } else {
            System.out.println("The answer is '" + response.getSolution() + "'");
        }

        return response.getSolution();
    }
}

  • No labels