SHARE
TWEET

2captcha api

423Million Jan 25th, 2020 217 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package andre;
  2.  
  3. import java.io.IOException;
  4.  
  5. public class TwoCaptcha {
  6.  
  7.     private String apiKey;
  8.     private String googleKey;
  9.     private String pageUrl;
  10.  
  11.     private HttpConnection connection;
  12.  
  13.     public TwoCaptcha(String apiKey, String googleKey, String pageUrl) {
  14.         this.apiKey = apiKey;
  15.         this.googleKey = googleKey;
  16.         this.pageUrl = pageUrl;
  17.         this.connection = new HttpConnection();
  18.     }
  19.  
  20.     public String solveCaptcha() throws InterruptedException, IOException {
  21.         String parameters = "key=" + this.apiKey + "&method=userrecaptcha" + "&googlekey=" + this.googleKey
  22.                 + "&pageurl=" + this.pageUrl;
  23.  
  24.         connection.get("http://2captcha.com/in.php?" + parameters);
  25.         String captchaId = connection.getHtml().replaceAll("\\D", "");
  26.  
  27.         do {
  28.             connection.get("http://2captcha.com/res.php?key=" + this.apiKey + "&action=get" + "&id=" + captchaId);
  29.             Thread.sleep(1000L);
  30.         } while (connection.getHtml().contains("NOT_READY"));
  31.        
  32.         String gRecaptchaResponse = connection.getHtml().replaceAll("OK\\|", "").replaceAll("\\n", "");
  33.         return gRecaptchaResponse;
  34.     }
  35.  
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top