extractOneValue

String scrapeableFile.extractOneValue ( String text, String extractorPatternName ) (professional and enterprise editions only)
String scrapeableFile.extractOneValue ( String text, String extractorPatternName, String extractorTokenName ) (professional and enterprise editions only)

Description

Manually retrieve the value of a single extractor token.

Parameters

  • text The string to which the extractor pattern will be applied.
  • extractorPatternName Name of extractor pattern in the scrapeable file, as a string. Optionally the scraping session and scrapeable file where the extractor pattern can be found can be specified in the form [scraping session:][scrapeable file:]extractor pattern.
  • extractorTokenName (optional) Extractor token name, as a string, whose matched value should be returned. If left off the matched value for the first extractor token in the data set will be returned.

Return Values

Returns the match from the last data record, as a string, on success. On failure it returns null and writes a error to the log.

Change Log

Version Description
4.5 Available for professional and enterprise editions.

If you want it to be from the first data record you could use getDataRecord.

Examples

Extract Value

 // Applies the extractor pattern "Product Name" to the data found in
 // the variable productDescriptionText. The extracted string is
 // stored in the productName variable.
 // Returns the value found in the first token found in the extractor pattern
 // or null if no token is found.

 productName = scrapeableFile.extractOneValue( productDescriptionText, "Product Name" );

Extract Value of Specified Token

 // Applies the extractor pattern "Product Name" to the data found in
 // the variable productDescriptionText. The extracted string is
 // stored in the productName variable.
 // Returns the value found in the token "NAME" found in the extractor pattern
 // or null if no token is found.

 productName = scrapeableFile.extractOneValue( productDescriptionText, "Product Name", "NAME" );

Extractor Pattern from another Scrapeable File

 // Apply extractor pattern "Product Name" from "Another scrapeable file"
 // to the variable productDescriptionText return the first "NAME"

 String productName = scrapeableFile.extractOneValue( productDescriptionText, "Another scrapeable file:Product Name", "NAME" );

Extractor Pattern from another Scraping Session

 // Apply extractor pattern "Product Name" from "Another scrapeable file"
 // in "Other scraping session" to the variable productDescriptionText
 // return the first "NAME"

 String productName = scrapeableFile.extractData( productDescriptionText,
                        "Other scraping session:Another scrapeable file:Product Name",
                       "NAME" );