addProgressBar
ProgressBar log.addProgressBar ( String title ) (enterprise edition only)
ProgressBar log.addProgressBar ( String title, String total ) (enterprise edition only)
ProgressBar log.addProgressBar ( String title, double total ) (enterprise edition only)
ProgressBar log.addProgressBarIfNotStopped ( String title ) (enterprise edition only)
ProgressBar log.addProgressBarIfNotStopped ( String title, String total ) (enterprise edition only)
ProgressBar log.addProgressBarIfNotStopped ( String title, double total ) (enterprise edition only)
Description
Adds a new progress bar. If no progress bar exists, this will be set as the root, otherwise it will be the child of the lowest progress bar. When web messages are output with the webDebug, webInfo, webWarn, or webError methods, a progress bar will be drawn to give a visual representation of the current progress of the scrape. The addProgressBarIfNotStopped versions remove the progress bar if the scrape has not been stopped, which is useful for determining when a scrape was stopped.
Parameters
- title The title for the new progress bar
- total (optional) The total for the new progress bar. This should be the total number of things this is tracking the progress of. For example, if used when iterating over each letter of the alphabet for a search, the total would be 26 (one for each letter).
Return Value
This method returns a reference to the new progress bar, which can be used to update the current progress
Change Log
Version |
Description |
5.5.29a |
Available in all editions. |
5.5.31a |
Available in enterprise edition. |
5.5.43a |
Moved from session to log class. |
Examples
Track the progress of a search over the alphabet
import com.screenscraper.util.ProgressBar;
ProgressBar bar = log.addProgressBar("Letter", 26);
for(char c = 'a'; c <= 'z'; c++)
{
session.setVariable("SEARCH_LETTER", c);
session.scrapeFile("Search");
bar.add(1);
// For Professional and Enterprise Editions
log.webInfo("Completed Search on: " + c);
// For Basic Edition ** Note that this method is available in Professional and Enterprise editions also
log.logMonitoredValues();
}
// Now that we have completed the search, remove the progress bar
log.removeProgressBar(bar);