getMaxScriptsOnStack
int session.getMaxScriptsOnStack ( )
Description
Get the total number of scripts allowed on the stack before the scraping session is forcibly stopped.
Parameters
This method does not receive any parameters.
Return Values
Returns max number of scripts that can be running at a time, as an integer.
Change Log
Version | Description |
---|---|
5.0 | Added for all editions. |
Examples
Check If More Scripts Can Be Run
import java.math.*;
// Get Number of Scripts (running and max)
BigDecimal numRunningScripts = new BigDecimal(session.getNumScriptsOnStack());
BigDecimal maxAllowedScripts = new BigDecimal(session.getMaxScriptsOnStack());
// Calculate percentage used
BigDecimal percentageUsedBD = numRunningScripts.divide(maxAllowedScripts, 2, BigDecimal.ROUND_HALF_UP);
double percentageUsed = percentageUsedBD.doubleValue();
if (percentageUsed < 90)
{
session.log(percentageUsed.toString() + "% of max scripts used");
}
else
{
session.logWarn("90% max scripts threshold has been reached.");
}
// Get Number of Scripts (running and max)
BigDecimal numRunningScripts = new BigDecimal(session.getNumScriptsOnStack());
BigDecimal maxAllowedScripts = new BigDecimal(session.getMaxScriptsOnStack());
// Calculate percentage used
BigDecimal percentageUsedBD = numRunningScripts.divide(maxAllowedScripts, 2, BigDecimal.ROUND_HALF_UP);
double percentageUsed = percentageUsedBD.doubleValue();
if (percentageUsed < 90)
{
session.log(percentageUsed.toString() + "% of max scripts used");
}
else
{
session.logWarn("90% max scripts threshold has been reached.");
}
See Also
- setMaxScriptsOnStack() [session] - Sets the maximum number of scripts that will be allowed on the stack.
- getNumScriptsOnStack() [session] - Gets the number of scripts currently on the stack.
scraper on 07/16/2010 at 5:19 pm
- Printer-friendly version
- Login or register to post comments