ImageDecoder

Overview

Class to convert images to text for interacting with CAPTCHA challenges. There are currently two implementations:

  • ManualDecoder: Creates a pop-up window for a user to enter in the text they read from the image
  • DecaptcherDecoder: Interface for the paid service decaptcher.com

When a reference to an image is passed to an instance of this class, it returns a DecodedImage object that can be queried for the resulting text, errors, and can report an image as poorly converted.

See example attached.

DecaptcherDecoder

void DecaptcherDecoder (ScrapingSession session, String username, String password, int port)
void DecaptcherDecoder (ScrapingSession session, String username, String password, String port)
void DecaptcherDecoder (ScrapingSession session, String username, String password, String port, String apiUrl)
void DecaptcherDecoder (ScrapingSession session, String username, String password, int port, String apiUrl)

Description

Requires an account with decaptcher.com.

Type of ImageDecoder in the com.screenscraper.util.images package that uses the decaptcher.com service to convert images to text. The constructor is DecaptcherDecoder(ScrapingSession session, String username, String password) or DecaptcherDecoder(ScrapingSession session, String username, String password, String apiUrl).

Parameters

  • session Name of currently running scraping session.
  • username Username used to log in to decaptcher.com service.
  • password Password used to log in to decaptcher.com service.
  • port The port given by De-captcher.com to access your account on their site.
  • apiUrl (optional) URL used to access decaptcher.com service. This setting will override the default URL.

Return Values

Returns void. If it runs into any problems accessing the decaptcher.com service an error will be thrown.

Change Log

Version Description
5.5.29a Available in all editions
5.5.40a Added the port parameter. The service now requires the correct port in order to authenticate.

Examples

Initialization script

import com.screenscraper.util.images.*;

ImageDecoder decoder;

decoder = new DecaptcherDecoder(session, "username", "password", 12345, "http://api.de-captcher.com");

session.setVariable("IMAGE_DECODER", decoder);

ManualDecoder

void ManualDecoder (ScrapingSession session)

Description

Type of ImageDecoder in the com.screenscraper.util.images package that uses a popup window prompting the user to enter the text read from an image. Useful for debugging purposes, as the input text should always be correct (so long as it is typed correctly). Helpful during testing to avoid costs associated with paid-for CAPTCHA decoding services such as decaptcher.com.

Parameters

  • session Name of currently running scraping session.

Return Values

Returns void. If it runs into any problems decoding an image an error will be thrown.

Change Log

Version Description
5.5.29a Available in all editions

Examples

Initialize script

import com.screenscraper.util.images.*;

ImageDecoder decoder;

decoder = new ManualDecoder(session);

session.setVariable("IMAGE_DECODER", decoder);

decodeFile

DecodedImage decodeFile ( String file )
DecodedImage decodeFile ( File file )

Description

Converts the image given to a DecodedImage that will handle it. Does not delete the file.

Parameters

  • file The image file

Return Value

A DecodedImage used to get the text, errors, and possibly report a result as bad.

Change Log

Version Description
5.5.29a Available in all editions.

Examples

image = decoder.decodeFile("path to the image file");

decodeURL

DecodedImage decodeURL ( String url )

Description

Converts the image at the given URL to a DecodedImage that will handle it. Temporarily saves the file in the screen-scraper root folder, but deletes it once it has been decoded. By default, this will use the scraping session's HttpClient to request the URL.

Parameters

  • url The url to the image

Return Value

A DecodedImage used to get the text, errors, and possibly report a result as bad.

Change Log

Version Description
5.5.29a Available in all editions.

Examples

DecodedImage image = decoder.decodeURL(dataRecord.get("IMAGE_URL"));