Class LoadOptions
-
- All Implemented Interfaces:
-
ai.platon.pulsar.common.config.Parameterized
public class LoadOptions extends CommonOptions
Load options are a set of parameters that define how a page should be loaded, including any specific behaviors or conditions that should be applied during the loading process.
The load options, or load arguments, can be a plain string in the form of command line parameters, and can be parsed into a LoadOptions object.
// parse a string into a LoadOptions object val options = session.options('-expires 1d -itemExpires 1d -ignoreFailure -parse -storeContent') // fetch after 1d since last fetch session.load('https://www.jd.com', '-expires 1d') // fetch immediately ignoring errors session.load('https://www.jd.com', '-refresh') // do not fetch after dead time session.load('https://www.jd.com', '-deadline 2022-04-15T18:36:54.941Z') // activate the parse phase session.load('https://www.jd.com', '-parse') // write the page content into storage session.load('https://www.jd.com', '-storeContent')
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classLoadOptions.Companion
-
Field Summary
-
Constructor Summary
Constructors Constructor Description LoadOptions(Array<String> argv, VolatileConfig conf, PageEventHandlers rawEvent, PageEventHandlers rawItemEvent, String referrer)
-
Method Summary
Modifier and Type Method Description final StringgetEntity()The entity name of the page, for example, article, product, hotel, flower, etc., it's optional. final UnitsetEntity(String entity)The entity name of the page, for example, article, product, hotel, flower, etc., it's optional. final StringgetLabel()The task label is optional and may be utilized to categorize tasks into groups. final UnitsetLabel(String label)The task label is optional and may be utilized to categorize tasks into groups. final StringgetTaskId()The taskId is optional and serves to differentiate tasks if needed. final UnitsetTaskId(String taskId)The taskId is optional and serves to differentiate tasks if needed. final InstantgetTaskTime()Task time is usually used to denote the name of a batch of tasks. final UnitsetTaskTime(Instant taskTime)Task time is usually used to denote the name of a batch of tasks. final InstantgetDeadline()The task's deadline indicates the time by which it should be completed. final UnitsetDeadline(Instant deadline)The task's deadline indicates the time by which it should be completed. final StringgetAuthToken()The auth token, used for authorization purpose. final UnitsetAuthToken(String authToken)The auth token, used for authorization purpose. final BooleangetReadonly()Specify whether the load execution is read-only or not. final UnitsetReadonly(Boolean readonly)Specify whether the load execution is read-only or not. final BooleanisResource()If true, fetch the url as a resource without browser rendering. final UnitsetResource(Boolean isResource)If true, fetch the url as a resource without browser rendering. final IntegergetPriority()Represents the priority of a task, determining the order of execution. final UnitsetPriority(Integer priority)Represents the priority of a task, determining the order of execution. final DurationgetExpires()The expiry duration. final UnitsetExpires(Duration expires)The expiry duration. final InstantgetExpireAt()The expiry time point. final UnitsetExpireAt(Instant expireAt)The expiry time point. final StringgetOutLinkSelector()The selector to extract links in portal pages. final UnitsetOutLinkSelector(String outLinkSelector)The selector to extract links in portal pages. final StringgetOutLinkPattern()The pattern to select out links in the portal page. final UnitsetOutLinkPattern(String outLinkPattern)The pattern to select out links in the portal page. final StringgetClickTarget()The selector for element to click. final UnitsetClickTarget(String clickTarget)The selector for element to click. final StringgetNextPageSelector()The selector for next page anchor. final UnitsetNextPageSelector(String nextPageSelector)The selector for next page anchor. final IntegergetIframe()The iframe id to switch to. final UnitsetIframe(Integer iframe)The iframe id to switch to. final IntegergetTopLinks()Specify how many links to extract for out pages. final UnitsetTopLinks(Integer topLinks)Specify how many links to extract for out pages. final StringgetWaitNonBlank()The selector specified element should have a non-blank text, the system should wait until the element is filled by a non-blank text, or until it times out. final UnitsetWaitNonBlank(String waitNonBlank)The selector specified element should have a non-blank text, the system should wait until the element is filled by a non-blank text, or until it times out. final StringgetRequireNotBlank()The selector specified element should have a non-blank text, the task should be retried if the element's text content is empty or blank. final UnitsetRequireNotBlank(String requireNotBlank)The selector specified element should have a non-blank text, the task should be retried if the element's text content is empty or blank. final IntegergetRequireSize()The minimum page size expected, if it is less than that, it will need to be re-fetched. final UnitsetRequireSize(Integer requireSize)The minimum page size expected, if it is less than that, it will need to be re-fetched. final IntegergetRequireImages()The minimum number of images expected in the page, if it is less than that, it will need to be re-fetched. final UnitsetRequireImages(Integer requireImages)The minimum number of images expected in the page, if it is less than that, it will need to be re-fetched. final IntegergetRequireAnchors()The minimum number of anchors expected in the page, if it is less than that, it will need to be re-fetched. final UnitsetRequireAnchors(Integer requireAnchors)The minimum number of anchors expected in the page, if it is less than that, it will need to be re-fetched. final FetchModegetFetchMode()The fetch mode. final UnitsetFetchMode(FetchMode fetchMode)The fetch mode. final BrowserTypegetBrowser()Specify which browser to use, google chrome is the default. final UnitsetBrowser(BrowserType browser)Specify which browser to use, google chrome is the default. final IntegergetScrollCount()The number of times the page should be scrolled down after it has just been opened in a browser. final UnitsetScrollCount(Integer scrollCount)The number of times the page should be scrolled down after it has just been opened in a browser. final DurationgetScrollInterval()The interval to scroll down. final UnitsetScrollInterval(Duration scrollInterval)The interval to scroll down. final DurationgetScriptTimeout()The maximum time to perform javascript injected into the browser. final UnitsetScriptTimeout(Duration scriptTimeout)The maximum time to perform javascript injected into the browser. final DurationgetPageLoadTimeout()The maximum time to wait for a page to finish. final UnitsetPageLoadTimeout(Duration pageLoadTimeout)The maximum time to wait for a page to finish. final BrowserTypegetItemBrowser()The browser used to visit the item pages. final UnitsetItemBrowser(BrowserType itemBrowser)The browser used to visit the item pages. final DurationgetItemExpires()The same as expires, but only works for item pages. final UnitsetItemExpires(Duration itemExpires)The same as expires, but only works for item pages. final InstantgetItemExpireAt()If an item page is expired, it should be fetched from the web again. final UnitsetItemExpireAt(Instant itemExpireAt)If an item page is expired, it should be fetched from the web again. final IntegergetItemScrollCount()The same as scrollCount, but only works for item pages. final UnitsetItemScrollCount(Integer itemScrollCount)The same as scrollCount, but only works for item pages. final DurationgetItemScrollInterval()The same as scrollInterval, but only works for item pages. final UnitsetItemScrollInterval(Duration itemScrollInterval)The same as scrollInterval, but only works for item pages. final DurationgetItemScriptTimeout()The same as scriptTimeout, but only works for item pages. final UnitsetItemScriptTimeout(Duration itemScriptTimeout)The same as scriptTimeout, but only works for item pages. final DurationgetItemPageLoadTimeout()The same as pageLoadTimeout, but only works for item pages. final UnitsetItemPageLoadTimeout(Duration itemPageLoadTimeout)The same as pageLoadTimeout, but only works for item pages. final StringgetItemWaitNonBlank()The selector specified element should have a non-blank text, the system should wait until the element is filled by a non-blank text, or until it times out. final UnitsetItemWaitNonBlank(String itemWaitNonBlank)The selector specified element should have a non-blank text, the system should wait until the element is filled by a non-blank text, or until it times out. final StringgetItemRequireNotBlank()Re-fetch the item pages if the required text is blank. final UnitsetItemRequireNotBlank(String itemRequireNotBlank)Re-fetch the item pages if the required text is blank. final IntegergetItemRequireSize()Re-fetch item pages smaller than requireSize. final UnitsetItemRequireSize(Integer itemRequireSize)Re-fetch item pages smaller than requireSize. final IntegergetItemRequireImages()Re-fetch item pages whose images is less than requireImages. final UnitsetItemRequireImages(Integer itemRequireImages)Re-fetch item pages whose images is less than requireImages. final IntegergetItemRequireAnchors()Re-fetch item pages with fewer anchors than the required number specified by requireAnchors. final UnitsetItemRequireAnchors(Integer itemRequireAnchors)Re-fetch item pages with fewer anchors than the required number specified by requireAnchors. final BooleangetPersist()Persist fetched pages as soon as possible. final UnitsetPersist(Boolean persist)Persist fetched pages as soon as possible. final BooleangetStoreContent()If false, do not persist the page content which is usually very large. final UnitsetStoreContent(Boolean storeContent)If false, do not persist the page content which is usually very large. final BooleangetDropContent()If the option is set, do not persist the page content which is usually very large. final UnitsetDropContent(Boolean dropContent)If the option is set, do not persist the page content which is usually very large. final BooleangetRefresh()Refresh the fetch state of a page, clear the retry counters. final UnitsetRefresh(Boolean refresh)final BooleangetIgnoreFailure()Retry fetching the page even if it's failed last time. final UnitsetIgnoreFailure(Boolean ignoreFailure)Retry fetching the page even if it's failed last time. final IntegergetNMaxRetry()Retry to fetch at most n times, if page.fetchRetries nMaxRetry, the page is marked as gone and do not fetch it again until -refresh is set to clear page. final UnitsetNMaxRetry(Integer nMaxRetry)Retry to fetch at most n times, if page.fetchRetries nMaxRetry, the page is marked as gone and do not fetch it again until -refresh is set to clear page. final IntegergetNJitRetry()Retry at most n times at fetch phase immediately if RETRY(1601) code return. final UnitsetNJitRetry(Integer nJitRetry)Retry at most n times at fetch phase immediately if RETRY(1601) code return. final BooleangetLazyFlush()If false, pages are flushed into database as soon as possible. final UnitsetLazyFlush(Boolean lazyFlush)If false, pages are flushed into database as soon as possible. final BooleangetIncognito()Run browser in incognito mode. final UnitsetIncognito(Boolean incognito)Run browser in incognito mode. final BooleangetNoRedirect()Do not redirect. final UnitsetNoRedirect(Boolean noRedirect)Do not redirect. final BooleangetHardRedirect()If false, return the original page record but the redirect target's content, otherwise, return the page record of the redirected target. final UnitsetHardRedirect(Boolean hardRedirect)If false, return the original page record but the redirect target's content, otherwise, return the page record of the redirected target. final BooleangetParse()If true, parse the page when it's just be fetched. final UnitsetParse(Boolean parse)If true, parse the page when it's just be fetched. final BooleangetReparseLinks()Reparse links if the page has been parsed before. final UnitsetReparseLinks(Boolean reparseLinks)Reparse links if the page has been parsed before. final BooleangetIgnoreUrlQuery()If true, remove the query parameters in the url. final UnitsetIgnoreUrlQuery(Boolean ignoreUrlQuery)If true, remove the query parameters in the url. final BooleangetNoNorm()If true, no normalizer will be applied when parse links. final UnitsetNoNorm(Boolean noNorm)If true, no normalizer will be applied when parse links. final BooleangetNoFilter()If true, no filter will be applied when parse links. final UnitsetNoFilter(Boolean noFilter)If true, no filter will be applied when parse links. final ConditiongetNetCondition()Indicates the network condition. final UnitsetNetCondition(Condition netCondition)Indicates the network condition. final IntegergetTest()The test level, 0 to disable, we will talk more in test mode. final UnitsetTest(Integer test)The test level, 0 to disable, we will talk more in test mode. final StringgetVersion()The load option version. final UnitsetVersion(String version)The load option version. final StringgetOutLinkSelectorOrNull()final PageEventHandlersgetEventHandlers()final PageEventHandlersgetItemEventHandlers()ParamsgetModifiedParams()Map<String, Object>getModifiedOptions()final VolatileConfiggetConf()final UnitsetConf(VolatileConfig conf)final PageEventHandlersgetRawEvent()final UnitsetRawEvent(PageEventHandlers rawEvent)final PageEventHandlersgetRawItemEvent()final UnitsetRawItemEvent(PageEventHandlers rawItemEvent)final StringgetReferrer()final UnitsetReferrer(String referrer)final BooleanparserEngaged()Booleanparse()Parse the arguments into LoadOptions with JCommander and with bug fixes. LoadOptionscreateItemOptions()Create a new LoadOptions object for item pages. final BooleanisExpired(Instant prevFetchTime)Check if the page expires. final BooleanisDead()If the page is dead, drop the task as soon as possible. UnititemOptions2MajorOptions()Convert the item options to major options. final VolatileConfigoverrideConfiguration()Write option values to conf. final VolatileConfigoverrideConfiguration(VolatileConfig conf)Write option values to conf. BooleanisDefault(String optionName)Check if the option value is the default. ParamsgetParams()Convert the LoadOptions to be a Params. StringtoString()Convert the LoadOptions to a string. Booleanequals(Object other)The equality check, two LoadOptions are equal only when the normalized arguments string are equal. IntegerhashCode()LoadOptionsclone()Create a new LoadOptions object with the same arguments string and event handlers. -
Methods inherited from class ai.platon.pulsar.skeleton.common.options.CommonOptions
isHelp, setHelp -
Methods inherited from class ai.platon.pulsar.skeleton.common.options.PulsarOptions
addObjects, getAcceptUnknownOptions, getAllowParameterOverwriting, getArgs, getArgv, getExpandAtSign, parseOrExit, setAcceptUnknownOptions, setAllowParameterOverwriting, setExpandAtSign, setObjects, toArgsMap, toArgv, toCmdLine, toMutableArgsMap, usage -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
LoadOptions
LoadOptions(Array<String> argv, VolatileConfig conf, PageEventHandlers rawEvent, PageEventHandlers rawItemEvent, String referrer)
-
-
Method Detail
-
getEntity
final String getEntity()
The entity name of the page, for example, article, product, hotel, flower, etc., it's optional.
-
setEntity
final Unit setEntity(String entity)
The entity name of the page, for example, article, product, hotel, flower, etc., it's optional.
-
getLabel
final String getLabel()
The task label is optional and may be utilized to categorize tasks into groups.
-
setLabel
final Unit setLabel(String label)
The task label is optional and may be utilized to categorize tasks into groups.
-
getTaskId
final String getTaskId()
The taskId is optional and serves to differentiate tasks if needed.
-
setTaskId
final Unit setTaskId(String taskId)
The taskId is optional and serves to differentiate tasks if needed.
-
getTaskTime
final Instant getTaskTime()
Task time is usually used to denote the name of a batch of tasks.
The task time is initialized to Instant.EPOCH, so parse() and toString() operations are symmetric.
-
setTaskTime
final Unit setTaskTime(Instant taskTime)
Task time is usually used to denote the name of a batch of tasks.
The task time is initialized to Instant.EPOCH, so parse() and toString() operations are symmetric.
-
getDeadline
final Instant getDeadline()
The task's deadline indicates the time by which it should be completed. If this deadline is surpassed, the task must be promptly discarded.
-
setDeadline
final Unit setDeadline(Instant deadline)
The task's deadline indicates the time by which it should be completed. If this deadline is surpassed, the task must be promptly discarded.
-
getAuthToken
final String getAuthToken()
The auth token, used for authorization purpose.
-
setAuthToken
final Unit setAuthToken(String authToken)
The auth token, used for authorization purpose.
-
getReadonly
final Boolean getReadonly()
Specify whether the load execution is read-only or not. When a load execution is read-only, it ensures that the webpage loaded remains unchanged by the execution.
-
setReadonly
final Unit setReadonly(Boolean readonly)
Specify whether the load execution is read-only or not. When a load execution is read-only, it ensures that the webpage loaded remains unchanged by the execution.
-
isResource
final Boolean isResource()
If true, fetch the url as a resource without browser rendering.
-
setResource
final Unit setResource(Boolean isResource)
If true, fetch the url as a resource without browser rendering.
-
getPriority
final Integer getPriority()
Represents the priority of a task, determining the order of execution.
The priority value is an integer where a smaller value indicates a higher priority. This is consistent with java.util.concurrent.PriorityBlockingQueue.
If the priority value is not within the range defined by Priority13, it will be adjusted to the nearest valid value. For example, a priority of -2001 will be adjusted to Priority13.HIGHER2.
Note: The priority specified in args or LoadOptions takes precedence over the priority in UrlAware, Hyperlink, etc.
Priority can be set in the following ways:
In the url, for example,
http://example.com -priority -2000In the args, for example,
Hyperlink("http://example.com", "", args = "-priority -2000")Int the LoadOptions object, for example,
session.load("http://example.com", options.apply { priority = -2000 })In the UrlAware object, for example,
Hyperlink("http://example.com", "", priority = -2000)
If a url is normalized like this:
session.normalize(url: UrlAware, options: LoadOptions)The priority will be set in the following order:
The priority in the url
The priority in the args
The priority in the options
Note: Consider use url args to set priority only.
Example:
session.load(url, "-priority 2000") val options = session.options("-priority 2000") session.load(url, options)
-
setPriority
final Unit setPriority(Integer priority)
Represents the priority of a task, determining the order of execution.
The priority value is an integer where a smaller value indicates a higher priority. This is consistent with java.util.concurrent.PriorityBlockingQueue.
If the priority value is not within the range defined by Priority13, it will be adjusted to the nearest valid value. For example, a priority of -2001 will be adjusted to Priority13.HIGHER2.
Note: The priority specified in args or LoadOptions takes precedence over the priority in UrlAware, Hyperlink, etc.
Priority can be set in the following ways:
In the url, for example,
http://example.com -priority -2000In the args, for example,
Hyperlink("http://example.com", "", args = "-priority -2000")Int the LoadOptions object, for example,
session.load("http://example.com", options.apply { priority = -2000 })In the UrlAware object, for example,
Hyperlink("http://example.com", "", priority = -2000)
If a url is normalized like this:
session.normalize(url: UrlAware, options: LoadOptions)The priority will be set in the following order:
The priority in the url
The priority in the args
The priority in the options
Note: Consider use url args to set priority only.
Example:
session.load(url, "-priority 2000") val options = session.options("-priority 2000") session.load(url, options)
-
getExpires
final Duration getExpires()
The expiry duration. If the expiry time is exceeded, the page should be fetched from the Internet.
The term "expires" usually be used for an expiry time, for example, http-equiv, or in cookie specification, guess it means "expires at".
The expires field supports both ISO-8601 standard and hadoop time duration format:
ISO-8601 standard : PnDTnHnMn.nS
Hadoop time duration format: 100s, 1m, 1h, 1d, valid units are : ns, us, ms, s, m, h, d.
-
setExpires
final Unit setExpires(Duration expires)
The expiry duration. If the expiry time is exceeded, the page should be fetched from the Internet.
The term "expires" usually be used for an expiry time, for example, http-equiv, or in cookie specification, guess it means "expires at".
The expires field supports both ISO-8601 standard and hadoop time duration format:
ISO-8601 standard : PnDTnHnMn.nS
Hadoop time duration format: 100s, 1m, 1h, 1d, valid units are : ns, us, ms, s, m, h, d.
-
getExpireAt
final Instant getExpireAt()
The expiry time point. If the expiry time is exceeded, the page should be fetched from the Internet.
Accept the following format:
yyyy-MM-dd[ HH[:mm:ss]]
ISO_INSTANT, or yyyy-MM-ddTHH:mm:ssZ
-
setExpireAt
final Unit setExpireAt(Instant expireAt)
The expiry time point. If the expiry time is exceeded, the page should be fetched from the Internet.
Accept the following format:
yyyy-MM-dd[ HH[:mm:ss]]
ISO_INSTANT, or yyyy-MM-ddTHH:mm:ssZ
-
getOutLinkSelector
final String getOutLinkSelector()
The selector to extract links in portal pages.
-
setOutLinkSelector
final Unit setOutLinkSelector(String outLinkSelector)
The selector to extract links in portal pages.
-
getOutLinkPattern
final String getOutLinkPattern()
The pattern to select out links in the portal page.
-
setOutLinkPattern
final Unit setOutLinkPattern(String outLinkPattern)
The pattern to select out links in the portal page.
-
getClickTarget
final String getClickTarget()
The selector for element to click. TODO: not implemented yet
-
setClickTarget
final Unit setClickTarget(String clickTarget)
The selector for element to click. TODO: not implemented yet
-
getNextPageSelector
final String getNextPageSelector()
The selector for next page anchor. TODO: not implemented yet
-
setNextPageSelector
final Unit setNextPageSelector(String nextPageSelector)
The selector for next page anchor. TODO: not implemented yet
-
setIframe
final Unit setIframe(Integer iframe)
The iframe id to switch to. TODO: not implemented yet
-
getTopLinks
final Integer getTopLinks()
Specify how many links to extract for out pages.
-
setTopLinks
final Unit setTopLinks(Integer topLinks)
Specify how many links to extract for out pages.
-
getWaitNonBlank
final String getWaitNonBlank()
The selector specified element should have a non-blank text, the system should wait until the element is filled by a non-blank text, or until it times out.
-
setWaitNonBlank
final Unit setWaitNonBlank(String waitNonBlank)
The selector specified element should have a non-blank text, the system should wait until the element is filled by a non-blank text, or until it times out.
-
getRequireNotBlank
final String getRequireNotBlank()
The selector specified element should have a non-blank text, the task should be retried if the element's text content is empty or blank.
-
setRequireNotBlank
final Unit setRequireNotBlank(String requireNotBlank)
The selector specified element should have a non-blank text, the task should be retried if the element's text content is empty or blank.
-
getRequireSize
final Integer getRequireSize()
The minimum page size expected, if it is less than that, it will need to be re-fetched.
The unit is byte.
-
setRequireSize
final Unit setRequireSize(Integer requireSize)
The minimum page size expected, if it is less than that, it will need to be re-fetched.
The unit is byte.
-
getRequireImages
final Integer getRequireImages()
The minimum number of images expected in the page, if it is less than that, it will need to be re-fetched.
-
setRequireImages
final Unit setRequireImages(Integer requireImages)
The minimum number of images expected in the page, if it is less than that, it will need to be re-fetched.
-
getRequireAnchors
final Integer getRequireAnchors()
The minimum number of anchors expected in the page, if it is less than that, it will need to be re-fetched.
-
setRequireAnchors
final Unit setRequireAnchors(Integer requireAnchors)
The minimum number of anchors expected in the page, if it is less than that, it will need to be re-fetched.
-
getFetchMode
final FetchMode getFetchMode()
The fetch mode.
Only BROWSER is supported currently.
-
setFetchMode
final Unit setFetchMode(FetchMode fetchMode)
The fetch mode.
Only BROWSER is supported currently.
-
getBrowser
final BrowserType getBrowser()
Specify which browser to use, google chrome is the default. TODO: session scope browser choice is not support by now
-
setBrowser
final Unit setBrowser(BrowserType browser)
Specify which browser to use, google chrome is the default. TODO: session scope browser choice is not support by now
-
getScrollCount
final Integer getScrollCount()
The number of times the page should be scrolled down after it has just been opened in a browser.
-
setScrollCount
final Unit setScrollCount(Integer scrollCount)
The number of times the page should be scrolled down after it has just been opened in a browser.
-
getScrollInterval
final Duration getScrollInterval()
The interval to scroll down.
-
setScrollInterval
final Unit setScrollInterval(Duration scrollInterval)
The interval to scroll down.
-
getScriptTimeout
final Duration getScriptTimeout()
The maximum time to perform javascript injected into the browser.
-
setScriptTimeout
final Unit setScriptTimeout(Duration scriptTimeout)
The maximum time to perform javascript injected into the browser.
-
getPageLoadTimeout
final Duration getPageLoadTimeout()
The maximum time to wait for a page to finish.
-
setPageLoadTimeout
final Unit setPageLoadTimeout(Duration pageLoadTimeout)
The maximum time to wait for a page to finish.
-
getItemBrowser
final BrowserType getItemBrowser()
The browser used to visit the item pages. TODO: session scope browser choice is not support by now
-
setItemBrowser
final Unit setItemBrowser(BrowserType itemBrowser)
The browser used to visit the item pages. TODO: session scope browser choice is not support by now
-
getItemExpires
final Duration getItemExpires()
The same as expires, but only works for item pages.
-
setItemExpires
final Unit setItemExpires(Duration itemExpires)
The same as expires, but only works for item pages.
-
getItemExpireAt
final Instant getItemExpireAt()
If an item page is expired, it should be fetched from the web again.
-
setItemExpireAt
final Unit setItemExpireAt(Instant itemExpireAt)
If an item page is expired, it should be fetched from the web again.
-
getItemScrollCount
final Integer getItemScrollCount()
The same as scrollCount, but only works for item pages.
-
setItemScrollCount
final Unit setItemScrollCount(Integer itemScrollCount)
The same as scrollCount, but only works for item pages.
-
getItemScrollInterval
final Duration getItemScrollInterval()
The same as scrollInterval, but only works for item pages.
-
setItemScrollInterval
final Unit setItemScrollInterval(Duration itemScrollInterval)
The same as scrollInterval, but only works for item pages.
-
getItemScriptTimeout
final Duration getItemScriptTimeout()
The same as scriptTimeout, but only works for item pages.
-
setItemScriptTimeout
final Unit setItemScriptTimeout(Duration itemScriptTimeout)
The same as scriptTimeout, but only works for item pages.
-
getItemPageLoadTimeout
final Duration getItemPageLoadTimeout()
The same as pageLoadTimeout, but only works for item pages.
-
setItemPageLoadTimeout
final Unit setItemPageLoadTimeout(Duration itemPageLoadTimeout)
The same as pageLoadTimeout, but only works for item pages.
-
getItemWaitNonBlank
final String getItemWaitNonBlank()
The selector specified element should have a non-blank text, the system should wait until the element is filled by a non-blank text, or until it times out.
-
setItemWaitNonBlank
final Unit setItemWaitNonBlank(String itemWaitNonBlank)
The selector specified element should have a non-blank text, the system should wait until the element is filled by a non-blank text, or until it times out.
-
getItemRequireNotBlank
final String getItemRequireNotBlank()
Re-fetch the item pages if the required text is blank.
-
setItemRequireNotBlank
final Unit setItemRequireNotBlank(String itemRequireNotBlank)
Re-fetch the item pages if the required text is blank.
-
getItemRequireSize
final Integer getItemRequireSize()
Re-fetch item pages smaller than requireSize.
-
setItemRequireSize
final Unit setItemRequireSize(Integer itemRequireSize)
Re-fetch item pages smaller than requireSize.
-
getItemRequireImages
final Integer getItemRequireImages()
Re-fetch item pages whose images is less than requireImages.
-
setItemRequireImages
final Unit setItemRequireImages(Integer itemRequireImages)
Re-fetch item pages whose images is less than requireImages.
-
getItemRequireAnchors
final Integer getItemRequireAnchors()
Re-fetch item pages with fewer anchors than the required number specified by requireAnchors.
-
setItemRequireAnchors
final Unit setItemRequireAnchors(Integer itemRequireAnchors)
Re-fetch item pages with fewer anchors than the required number specified by requireAnchors.
-
getPersist
final Boolean getPersist()
Persist fetched pages as soon as possible.
-
setPersist
final Unit setPersist(Boolean persist)
Persist fetched pages as soon as possible.
-
getStoreContent
final Boolean getStoreContent()
If false, do not persist the page content which is usually very large.
-
setStoreContent
final Unit setStoreContent(Boolean storeContent)
If false, do not persist the page content which is usually very large.
-
getDropContent
final Boolean getDropContent()
If the option is set, do not persist the page content which is usually very large. If the option is true, it overrides storeContent.
Example:
session.load(url, "-dropContent") val options = session.options("-dropContent") session.load(url, options)
-
setDropContent
final Unit setDropContent(Boolean dropContent)
If the option is set, do not persist the page content which is usually very large. If the option is true, it overrides storeContent.
Example:
session.load(url, "-dropContent") val options = session.options("-dropContent") session.load(url, options)
-
getRefresh
final Boolean getRefresh()
Refresh the fetch state of a page, clear the retry counters. If true, the page should be fetched, just like we click the refresh button on a real browser. The option can be explained as follows: -refresh = -ignoreFailure -i 0s and set page.fetchRetries = 0.
TODO: consider add an option itemRefresh
-
setRefresh
final Unit setRefresh(Boolean refresh)
-
getIgnoreFailure
final Boolean getIgnoreFailure()
Retry fetching the page even if it's failed last time.
-
setIgnoreFailure
final Unit setIgnoreFailure(Boolean ignoreFailure)
Retry fetching the page even if it's failed last time.
-
getNMaxRetry
final Integer getNMaxRetry()
Retry to fetch at most n times, if page.fetchRetries nMaxRetry, the page is marked as gone and do not fetch it again until -refresh is set to clear page.fetchRetries
-
setNMaxRetry
final Unit setNMaxRetry(Integer nMaxRetry)
Retry to fetch at most n times, if page.fetchRetries nMaxRetry, the page is marked as gone and do not fetch it again until -refresh is set to clear page.fetchRetries
-
getNJitRetry
final Integer getNJitRetry()
Retry at most n times at fetch phase immediately if RETRY(1601) code return.
-
setNJitRetry
final Unit setNJitRetry(Integer nJitRetry)
Retry at most n times at fetch phase immediately if RETRY(1601) code return.
-
getLazyFlush
final Boolean getLazyFlush()
If false, pages are flushed into database as soon as possible.
-
setLazyFlush
final Unit setLazyFlush(Boolean lazyFlush)
If false, pages are flushed into database as soon as possible.
-
getIncognito
final Boolean getIncognito()
Run browser in incognito mode. Not used since the browser always running in temporary contexts.
-
setIncognito
final Unit setIncognito(Boolean incognito)
Run browser in incognito mode. Not used since the browser always running in temporary contexts.
-
getNoRedirect
final Boolean getNoRedirect()
Do not redirect. Ignored in browser mode since the browser handles the redirection itself.
-
setNoRedirect
final Unit setNoRedirect(Boolean noRedirect)
Do not redirect. Ignored in browser mode since the browser handles the redirection itself.
-
getHardRedirect
final Boolean getHardRedirect()
If false, return the original page record but the redirect target's content, otherwise, return the page record of the redirected target. If we use a browser, redirections are handled by the browser so the flag is ignored.
-
setHardRedirect
final Unit setHardRedirect(Boolean hardRedirect)
If false, return the original page record but the redirect target's content, otherwise, return the page record of the redirected target. If we use a browser, redirections are handled by the browser so the flag is ignored.
-
getReparseLinks
final Boolean getReparseLinks()
Reparse links if the page has been parsed before.
-
setReparseLinks
final Unit setReparseLinks(Boolean reparseLinks)
Reparse links if the page has been parsed before.
-
getIgnoreUrlQuery
final Boolean getIgnoreUrlQuery()
If true, remove the query parameters in the url.
-
setIgnoreUrlQuery
final Unit setIgnoreUrlQuery(Boolean ignoreUrlQuery)
If true, remove the query parameters in the url.
-
setNoNorm
final Unit setNoNorm(Boolean noNorm)
If true, no normalizer will be applied when parse links.
-
getNoFilter
final Boolean getNoFilter()
If true, no filter will be applied when parse links.
-
setNoFilter
final Unit setNoFilter(Boolean noFilter)
If true, no filter will be applied when parse links.
-
getNetCondition
final Condition getNetCondition()
Indicates the network condition.
-
setNetCondition
final Unit setNetCondition(Condition netCondition)
Indicates the network condition.
-
setTest
final Unit setTest(Integer test)
The test level, 0 to disable, we will talk more in test mode.
-
getVersion
final String getVersion()
The load option version.
-
setVersion
final Unit setVersion(String version)
The load option version.
-
getOutLinkSelectorOrNull
final String getOutLinkSelectorOrNull()
-
getEventHandlers
final PageEventHandlers getEventHandlers()
-
getItemEventHandlers
final PageEventHandlers getItemEventHandlers()
-
getModifiedParams
Params getModifiedParams()
-
getModifiedOptions
Map<String, Object> getModifiedOptions()
-
getConf
final VolatileConfig getConf()
-
getRawEvent
final PageEventHandlers getRawEvent()
-
setRawEvent
final Unit setRawEvent(PageEventHandlers rawEvent)
-
getRawItemEvent
final PageEventHandlers getRawItemEvent()
-
setRawItemEvent
final Unit setRawItemEvent(PageEventHandlers rawItemEvent)
-
getReferrer
final String getReferrer()
-
setReferrer
final Unit setReferrer(String referrer)
-
parserEngaged
final Boolean parserEngaged()
-
parse
Boolean parse()
Parse the arguments into LoadOptions with JCommander and with bug fixes.
-
createItemOptions
LoadOptions createItemOptions()
Create a new LoadOptions object for item pages.
-
isExpired
final Boolean isExpired(Instant prevFetchTime)
Check if the page expires.
A page is expired when:
-
itemOptions2MajorOptions
Unit itemOptions2MajorOptions()
Convert the item options to major options. The system do not use item options directly, we have to do the convert before we process item pages.
-
overrideConfiguration
final VolatileConfig overrideConfiguration()
Write option values to conf.
LoadOptions is not globally visible, we have to pass values to modules which can not see it through a VolatileConfig object.
-
overrideConfiguration
final VolatileConfig overrideConfiguration(VolatileConfig conf)
Write option values to conf.
LoadOptions is not globally visible, we have to pass values to modules which can not see it through a VolatileConfig object.
-
isDefault
Boolean isDefault(String optionName)
Check if the option value is the default.
- Parameters:
optionName- the option name, without the leading-
-
getParams
Params getParams()
Convert the LoadOptions to be a Params.
-
toString
String toString()
Convert the LoadOptions to a string. The two operations parse and toString are reversible:
val args = "..." val options1 = LoadOptions.parse(args) val normalizedArgs = options1 val options2 = LoadOptions.parse(normalizedArgs) require(normalizedArgs == options2.toString())
-
equals
Boolean equals(Object other)
The equality check, two LoadOptions are equal only when the normalized arguments string are equal.
-
clone
LoadOptions clone()
Create a new LoadOptions object with the same arguments string and event handlers.
-
-
-
-