public class DomSimulator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
LOCAL_STORAGE_SESSION_VARIABLE
The name of the session variable used to store local session storage for the ScriptEngine
|
static java.lang.String |
SESSION_STORAGE_SESSION_VARIABLE
The name of the session variable used to store session storage for the ScriptEngine
|
Modifier and Type | Method and Description |
---|---|
static java.lang.Runnable |
convertFunctionToRunnable(java.lang.Runnable runnable)
Simple method for use in javascript to convert a function call to a runnable (for methods that take Callable or Runnable)
|
static ComplexJavaScriptEngine |
getComplexJavaScriptEngine(ScrapingSession session,
ScrapeableFile scrapeableFile,
IssuedRequestHandler issuedRequestHandler,
java.lang.String pageContent)
Gets a script engine setup to run javascript more like a browser.
|
static javax.script.ScriptEngine |
getSimpleJavaScriptEngine(ScrapingSession session,
ScrapeableFile scrapeableFile)
Gets a script engine setup to run javascript for the scrapeable file (note this won't modify the last response tab data).
|
static javax.script.ScriptEngine |
getSimpleJavaScriptEngine(ScrapingSession session,
java.lang.String url,
java.lang.String referrer,
java.lang.String encoding,
java.lang.String userAgent,
java.lang.String pageContent)
Gets a script engine setup to run javascript for the given input data.
|
static java.util.Map<java.lang.String,java.lang.String> |
parseUserAgentString(java.lang.String inputString)
Parses a user agent string into parts a browser would indicate
|
public static final java.lang.String LOCAL_STORAGE_SESSION_VARIABLE
public static final java.lang.String SESSION_STORAGE_SESSION_VARIABLE
@InternalOnly public static java.lang.Runnable convertFunctionToRunnable(java.lang.Runnable runnable)
runnable
- The input function@NotNull @InternalOnly public static java.util.Map<java.lang.String,java.lang.String> parseUserAgentString(@NotNull java.lang.String inputString)
inputString
- The input string@NotNull @RequiredVersion(value=2) public static ComplexJavaScriptEngine getComplexJavaScriptEngine(@NotNull ScrapingSession session, @Nullable ScrapeableFile scrapeableFile, @Nullable IssuedRequestHandler issuedRequestHandler, @NotNull java.lang.String pageContent) throws javax.script.ScriptException
engine.eval("ScrapeEnv.close()");
. If you don't close it it will leak the scheduling thread it uses (but only if the
setTimeout or setInterval methods were called in the javascript). As of version 7.0.6a this will call the close method at the end of the scraping session.
You should still close it prior to that to release resources, but it should clean itself if you didn'tsession
- The current scraping sessionscrapeableFile
- The current scrapeable file (used for some extra details for the current page, but not required)issuedRequestHandler
- A handler for the requests issued to load pages and scripts, or null to use a default onepageContent
- The content of the page (not including headers) to use for the DOMjavax.script.ScriptException
- If there is an error executing the setup code@RequiredVersion(value=2) public static javax.script.ScriptEngine getSimpleJavaScriptEngine(@NotNull ScrapingSession session, @NotNull ScrapeableFile scrapeableFile) throws java.net.URISyntaxException, javax.script.ScriptException
session
- The current scraping sessionscrapeableFile
- The scrapeable file for which to build the objectsjava.net.URISyntaxException
- If the url for the scrapeable file is invalidjavax.script.ScriptException
- If there is an error executing the setup code@RequiredVersion(value=2) public static javax.script.ScriptEngine getSimpleJavaScriptEngine(@NotNull ScrapingSession session, @NotNull java.lang.String url, @Nullable java.lang.String referrer, @NotNull java.lang.String encoding, @NotNull java.lang.String userAgent, @NotNull java.lang.String pageContent) throws java.net.URISyntaxException, javax.script.ScriptException
session
- The current session (used for logging or other session related stuff)url
- The url for the current pagereferrer
- The referring urlencoding
- The encoding used when parsinguserAgent
- The user agent string used to request the contentpageContent
- The content of the page for which we are building the datajava.net.URISyntaxException
- If the url is invalidjavax.script.ScriptException
- If there is an error executing the setup code