Advertisement
Guest User

Untitled

a guest
Sep 21st, 2016
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.74 KB | None | 0 0
  1. import com.DeathByCaptcha.AccessDeniedException;
  2. import com.DeathByCaptcha.Client;
  3. import com.DeathByCaptcha.HttpClient;
  4. import com.DeathByCaptcha.SocketClient;
  5. import com.DeathByCaptcha.Captcha;
  6.  
  7. import java.io.IOException;
  8.  
  9.  
  10. class ExampleNewRecaptcha
  11. {
  12. public static void main(String[] args)
  13. throws Exception
  14. {
  15. // EXAMPLE RECAPTCHA_COORDINATES.
  16.  
  17. // Put your DBC username & password here:
  18. //Client client = (Client)(new HttpClient(args[0], args[1]));
  19. String username = "your_username_here";
  20. String password = "your_password_here";
  21. String filename = "test.jpg";
  22. Client client = (Client)(new SocketClient(username, password));
  23. client.isVerbose = true;
  24.  
  25. try {
  26. try {
  27. System.out.println("Your balance is " + client.getBalance() + " US cents");
  28. } catch (IOException e) {
  29. System.out.println("Failed fetching balance: " + e.toString());
  30. return;
  31. }
  32.  
  33. Captcha captcha = null;
  34. try {
  35. // Upload a CAPTCHA and poll for its status with 120 seconds timeout.
  36. // Put you CAPTCHA image file name, file object, input stream, or
  37. // vector of bytes, and solving timeout (in seconds) if 0 the default value take place.
  38. // please note we are specifying type=2 in the second argument
  39. captcha = client.decode(filename, 2, 0);
  40. } catch (IOException e) {
  41. System.out.println("Failed uploading CAPTCHA");
  42. return;
  43. }
  44. if (null != captcha) {
  45. System.out.println("CAPTCHA " + captcha.id + " solved: " + captcha.text);
  46.  
  47. // Report incorrectly solved CAPTCHA if necessary.
  48. // Make sure you've checked if the CAPTCHA was in fact incorrectly
  49. // solved, or else you might get banned as abuser.
  50. /*try {
  51. if (client.report(captcha)) {
  52. System.out.println("Reported as incorrectly solved");
  53. } else {
  54. System.out.println("Failed reporting incorrectly solved CAPTCHA");
  55. }
  56. } catch (IOException e) {
  57. System.out.println("Failed reporting incorrectly solved CAPTCHA: " + e.toString());
  58. }*/
  59. } else {
  60. System.out.println("Failed solving CAPTCHA");
  61. }
  62. } catch (com.DeathByCaptcha.Exception e) {
  63. System.out.println(e);
  64. }
  65.  
  66. // EXAMPLE RECAPTCHA_IMAGE_GROUP.
  67.  
  68. // Put your DBC username & password here:
  69. //Client client = (Client)(new HttpClient(args[0], args[1]));
  70. filename = "test2.jpg";
  71. String banner = "banner.jpg";
  72. String banner_text = "choose all pizza:";
  73.  
  74. try {
  75. try {
  76. System.out.println("Your balance is " + client.getBalance() + " US cents");
  77. } catch (IOException e) {
  78. System.out.println("Failed fetching balance: " + e.toString());
  79. return;
  80. }
  81.  
  82. Captcha captcha = null;
  83. try {
  84. // Upload a CAPTCHA and poll for its status with 120 seconds timeout.
  85. // Put you CAPTCHA image file name, file object, input stream, or
  86. // vector of bytes, and solving timeout (in seconds) if 0 the default value take place.
  87. // please note we are specifying banner, banner_test and type=3 in the second argument
  88. captcha = client.decode(filename, 3, banner, banner_text, 0);
  89. //you can supply optional `grid` argument to decode() call, with a
  90. //string like 3x3 or 2x4, defining what grid individual images were located at
  91. //example:
  92. // captcha = client.decode(filename, 3, banner, banner_text, "2x4", 0);
  93. //see 2x4.png example image to have an idea what that images look like
  94. //If you wont supply `grid` argument, dbc will attempt to autodetect the grid
  95. } catch (IOException e) {
  96. System.out.println("Failed uploading CAPTCHA");
  97. return;
  98. }
  99. if (null != captcha) {
  100. System.out.println("CAPTCHA " + captcha.id + " solved: " + captcha.text);
  101.  
  102. // Report incorrectly solved CAPTCHA if necessary.
  103. // Make sure you've checked if the CAPTCHA was in fact incorrectly
  104. // solved, or else you might get banned as abuser.
  105. /*try {
  106. if (client.report(captcha)) {
  107. System.out.println("Reported as incorrectly solved");
  108. } else {
  109. System.out.println("Failed reporting incorrectly solved CAPTCHA");
  110. }
  111. } catch (IOException e) {
  112. System.out.println("Failed reporting incorrectly solved CAPTCHA: " + e.toString());
  113. }*/
  114. } else {
  115. System.out.println("Failed solving CAPTCHA");
  116. }
  117. } catch (com.DeathByCaptcha.Exception e) {
  118. System.out.println(e);
  119. }
  120.  
  121. }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement