forked from 2captcha/2captcha-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotateExample.java
More file actions
30 lines (21 loc) · 831 Bytes
/
RotateExample.java
File metadata and controls
30 lines (21 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package examples;
import com.twocaptcha.TwoCaptcha;
import com.twocaptcha.captcha.Rotate;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
public class RotateExample {
public static void main(String[] args) throws Exception {
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
byte[] bytes = Files.readAllBytes(Paths.get("src/main/resources/rotate.jpg"));
String base64EncodedImage = Base64.getEncoder().encodeToString(bytes);
Rotate captcha = new Rotate();
captcha.setBase64(base64EncodedImage);
try {
solver.solve(captcha);
System.out.println("Captcha solved: " + captcha.getCode());
} catch (Exception e) {
System.out.println("Error occurred: " + e.getMessage());
}
}
}