Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • 2Captcha Solver Snippet [USING SELENIUM]


    Defiled

    Recommended Posts

    Hello,

    This is a snippet on solving 2Captcha using Selenium, you of course need 3 classes to use this (HttpWrapper, TwoCaptchaService, ProxyType) which are found in the 2Captcha Java API.

        private void solveCaptcha(String apiKey, String pageUrl, String siteKey) {
            TwoCaptchaService service = new TwoCaptchaService(apiKey, siteKey, pageUrl);
            try {
                String responseToken = service.solveCaptcha();
                if(responseToken.equals("ERROR_CAPTCHA_UNSOLVABLE")) {
                    System.out.println("Unable to solve.. Resolving.. ");
                    solveCaptcha(apiKey, pageUrl, siteKey);
                } else {
                    System.out.println("Solved and Generated Response Token..  "+responseToken);
                    JavascriptExecutor js = (JavascriptExecutor) driver;
                    js.executeScript("document.getElementById('g-recaptcha-response').innerHTML = '" + responseToken + "';");
                  	js.executeScript("onSubmit()");
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    If the page does not contain the callback function onSubmit() or contains it but within an anonymous function, you have 2 ways to do it:

    /*
    Using the Browser console find the lettering that points to the anonymous function and replace cl.J with yours.
    */
    js.executeScript("___grecaptcha_cfg.clients[0].cl.J.callback(\"" + responseToken + "\")");  
    OR
    /*
    This simply calls back any callback method it finds.
    */
    js.executeScript("document.getElementById('callback').call();");

    I hope this helps someone :) improvements are welcome

    Link to comment
    Share on other sites

    11 hours ago, Eclipseop said:

    hello Good squire! 

     

    I am here to inform u that using selenium is so 2017 l00l

    It's open for anyone to use, Mr. Otter. If you wanna use Selenium, go for it.. If you wanna use Apache HTTP go for it.. if you wanna use a Toaster go for it.. ;)

     

    PST: The same code can be applied to other software... you just have to change the way it executes the Javascript code. :) 

    Kind Regards,

    The Good Squire

    Link to comment
    Share on other sites

    • 2 months later...
    On 3/2/2020 at 2:03 AM, Defiled said:

    It's open for anyone to use, Mr. Otter. If you wanna use Selenium, go for it.. If you wanna use Apache HTTP go for it.. if you wanna use a Toaster go for it.. ;)

     

    PST: The same code can be applied to other software... you just have to change the way it executes the Javascript code. :) 

    Kind Regards,

    The Good Squire

    whats the lastest, most efficient methodology rather than using selenium cuz its free

    there have to be some better cost-efficient methods

    Link to comment
    Share on other sites

    On 3/1/2020 at 5:02 PM, Eclipseop said:

    hello Good squire! 

     

    I am here to inform u that using selenium is so 2017 l00l

    what's the 2020 method? x_x

    Link to comment
    Share on other sites

    On 3/1/2020 at 11:30 AM, Defiled said:

    Hello,

    This is a snippet on solving 2Captcha using Selenium, you of course need 3 classes to use this (HttpWrapper, TwoCaptchaService, ProxyType) which are found in the 2Captcha Java API.

    
        private void solveCaptcha(String apiKey, String pageUrl, String siteKey) {
            TwoCaptchaService service = new TwoCaptchaService(apiKey, siteKey, pageUrl);
            try {
                String responseToken = service.solveCaptcha();
                if(responseToken.equals("ERROR_CAPTCHA_UNSOLVABLE")) {
                    System.out.println("Unable to solve.. Resolving.. ");
                    solveCaptcha(apiKey, pageUrl, siteKey);
                } else {
                    System.out.println("Solved and Generated Response Token..  "+responseToken);
                    JavascriptExecutor js = (JavascriptExecutor) driver;
                    js.executeScript("document.getElementById('g-recaptcha-response').innerHTML = '" + responseToken + "';");
                  	js.executeScript("onSubmit()");
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    If the page does not contain the callback function onSubmit() or contains it but within an anonymous function, you have 2 ways to do it:

    
    /*
    Using the Browser console find the lettering that points to the anonymous function and replace cl.J with yours.
    */
    js.executeScript("___grecaptcha_cfg.clients[0].cl.J.callback(\"" + responseToken + "\")");  
    OR
    /*
    This simply calls back any callback method it finds.
    */
    js.executeScript("document.getElementById('callback').call();");

    I hope this helps someone :) improvements are welcome

    little doubt, how do you get the "driver" variable inside the function? do you send it as a parameter?

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.