public class TwoCaptchaDecoder extends ImageDecoder
Modifier and Type | Field and Description |
---|---|
static int |
EITHER_NUMERIC_OR_LETTERS_CAPTCHA
Constant for captcha can contain both letters and numbers
|
static int |
LETTERS_CAPTCHA
Constant for captcha should only contain letters
|
static int |
NUMERIC_CAPTCHA
Constant for captcha should only contain numbers
|
static int |
UNSPECIFIED_CAPTCHA_TYPE
Constant for captcha type unspecified (let the captcha solver decide how to handle it)
|
session
Constructor and Description |
---|
TwoCaptchaDecoder(ScrapingSession session,
java.lang.String apiKey)
Instantiates a new TwoCaptchaDecoder for the given session with the provided API key.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes any resources associated with the decoder.
|
DecodedImage |
decodeFile(java.io.File file)
Converts the image given to a DecodedImage that will handle it.
|
DecodedImage |
decodeFile(java.io.File file,
boolean phraseContainsTwoWords,
boolean isCaseSensitive,
int numericFlag,
boolean mathCaptcha)
Returns the solution to the given captcha image file as a DecodedImage.
|
double |
getBalance()
Returns the current balance of the account (if it can be accessed via the API).
|
com.screenscraper.util.images.TwoCaptchaDecoder.TwoCaptchaResponse |
solveReCaptcha2Captcha(java.lang.String siteKey,
java.lang.String pageURL)
Returns the solution to the given reCaptcha 2.0 captcha.
|
com.screenscraper.util.images.TwoCaptchaDecoder.TwoCaptchaResponse |
solveRotateCaptcha(java.lang.Integer angle,
java.io.File... images)
Returns the solution to the given rotate captcha.
|
com.screenscraper.util.images.TwoCaptchaDecoder.TwoCaptchaResponse |
solveRotateCaptcha(java.lang.Integer angle,
java.io.File image)
Returns the solution to the given rotate captcha.
|
com.screenscraper.util.images.TwoCaptchaDecoder.TwoCaptchaResponse |
solveTextCaptcha(java.lang.String text,
java.lang.String instructions)
Returns the solution to the given text captcha, using the specified instructions.
|
java.lang.String |
toString() |
decodeFile, decodeURL, setAutoCloseAfterScrapeEnds
public static final int UNSPECIFIED_CAPTCHA_TYPE
public static final int NUMERIC_CAPTCHA
public static final int LETTERS_CAPTCHA
public static final int EITHER_NUMERIC_OR_LETTERS_CAPTCHA
public TwoCaptchaDecoder(@NotNull ScrapingSession session, @NotNull java.lang.String apiKey)
session
- The current scraping session.apiKey
- Your https://2captcha.com API key.@NotNull public com.screenscraper.util.images.TwoCaptchaDecoder.TwoCaptchaResponse solveTextCaptcha(@NotNull java.lang.String text, @Nullable java.lang.String instructions)
text
- the text captcha. Cannot exceed 140 characters.instructions
- the instructions to solve the captcha. Cannot exceed 140 characters.@NotNull public com.screenscraper.util.images.TwoCaptchaDecoder.TwoCaptchaResponse solveReCaptcha2Captcha(@NotNull java.lang.String siteKey, @NotNull java.lang.String pageURL)
siteKey
- The google key for the site with reCaptcha 2.0. This value won't change for a site unless the site admin manually updates it.pageURL
- The URL of the page, which is required for captcha resolution to succeed@NotNull public com.screenscraper.util.images.TwoCaptchaDecoder.TwoCaptchaResponse solveRotateCaptcha(@Nullable java.lang.Integer angle, java.io.File image)
angle
- The rotation angle to use (defaults to 40, which is for FunCaptcha)image
- The image that is to be rotated@NotNull public com.screenscraper.util.images.TwoCaptchaDecoder.TwoCaptchaResponse solveRotateCaptcha(@Nullable java.lang.Integer angle, java.io.File... images)
angle
- The rotation angle to use (defaults to 40, which is for FunCaptcha)images
- The images that are to be rotated@NotNull public DecodedImage decodeFile(@NotNull java.io.File file)
ImageDecoder
decodeFile
in class ImageDecoder
file
- The image file@NotNull public DecodedImage decodeFile(@NotNull java.io.File file, boolean phraseContainsTwoWords, boolean isCaseSensitive, int numericFlag, boolean mathCaptcha)
file
- the captcha image file.phraseContainsTwoWords
- false if the captcha only contains one word, true if it contains two.isCaseSensitive
- indicates whether or not the captcha is case sensitive.numericFlag
- specifies the type of captcha. Use static constants provided in this class to specify value.mathCaptcha
- indicates whether or not math is required for the captcha.public double getBalance()
ImageDecoder
getBalance
in class ImageDecoder
public void close()
ImageDecoder
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class ImageDecoder
@NotNull public java.lang.String toString()
toString
in class java.lang.Object