-
Notifications
You must be signed in to change notification settings - Fork 17
/
AudioOptionsExample.java
35 lines (27 loc) · 1.02 KB
/
AudioOptionsExample.java
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
31
32
33
34
35
package examples;
import com.twocaptcha.TwoCaptcha;
import com.twocaptcha.captcha.Audio;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
public class AudioOptionsExample {
public static void main(String[] args) throws Exception {
TwoCaptcha solver = new TwoCaptcha(args[0]);
solver.setHost("rucaptcha.com");
solver.setSoftId(0);
solver.setDefaultTimeout(120);
solver.setRecaptchaTimeout(600);
solver.setPollingInterval(10);
byte[] bytes = Files.readAllBytes(Paths.get("src/main/resources/audio-ru.mp3"));
String base64EncodedImage = Base64.getEncoder().encodeToString(bytes);
Audio captcha = new Audio();
captcha.setBase64(base64EncodedImage);
captcha.setLang("ru");
try {
solver.solve(captcha);
System.out.println("Captcha solved: " + captcha.getCode());
} catch (Exception e) {
System.out.println("Error occurred: " + e.getMessage());
}
}
}