Class PulsarSettings
-
- All Implemented Interfaces:
public final class PulsarSettingsThe PulsarSettings class defines a convenient interface to control the behavior of Browser4.
For example, to run multiple temporary browsers in headless mode, which is usually used in the spider scenario, you can use the following code:
PulsarSettings .headless() .maxBrowsers(4) .maxOpenTabs(12) .enableUrlBlocking()The above code will:
Run the browser in headless mode
Set the number of privacy contexts to 4
Set the max number of open tabs in each browser context to 12
Enable url blocking
If you want to run your system's default browser in GUI mode, and interact with the webpage, you can use the following code:
PulsarSettings.withSystemDefaultBrowser().withGUI().withSPA()The above code will:
Use the system's default browser
Run the browser in GUI mode
Set the system to work with single page application
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classPulsarSettings.Companion
-
Field Summary
Fields Modifier and Type Field Description private final Booleanspaprivate final DisplayModedisplayModeprivate final IntegermaxBrowsersprivate final IntegermaxOpenTabsprivate final InteractSettingsinteractSettingsprivate final BrowserProfileModeprofileModepublic final static PulsarSettings.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description PulsarSettings(Boolean spa, DisplayMode displayMode, Integer maxBrowsers, Integer maxOpenTabs, InteractSettings interactSettings, BrowserProfileMode profileMode)
-
Method Summary
Modifier and Type Method Description final BooleangetSpa()final DisplayModegetDisplayMode()final IntegergetMaxBrowsers()final IntegergetMaxOpenTabs()final InteractSettingsgetInteractSettings()final BrowserProfileModegetProfileMode()final UnitoverrideSystemProperties()final UnitoverrideConfiguration(MutableConfig conf)final static PulsarSettings.CompanionwithBrowserContextMode(BrowserProfileMode contextMode, MutableConfig conf)final static PulsarSettings.CompanionwithBrowserContextMode(BrowserProfileMode contextMode)final static PulsarSettings.CompanionwithBrowserContextMode(BrowserProfileMode contextMode, BrowserType browserType, MutableConfig conf)final static PulsarSettings.CompanionwithBrowserContextMode(BrowserProfileMode contextMode, BrowserType browserType)final static PulsarSettings.CompanionwithBrowser(BrowserType browserType, MutableConfig conf)final static PulsarSettings.CompanionwithBrowser(BrowserType browserType)final static PulsarSettings.CompanionwithSystemDefaultBrowser(MutableConfig conf)Use the system's default Chrome browser, so Browser4 visits websites just like you do. final static PulsarSettings.CompanionwithSystemDefaultBrowser()Use the system's default Chrome browser, so Browser4 visits websites just like you do. final static PulsarSettings.CompanionwithSystemDefaultBrowser(BrowserType browserType, MutableConfig conf)Use the system's default browser with the given type, so Browser4 visits websites just like you do. final static PulsarSettings.CompanionwithSystemDefaultBrowser(BrowserType browserType)Use the system's default browser with the given type, so Browser4 visits websites just like you do. final static PulsarSettings.CompanionwithDefaultBrowser(MutableConfig conf)Use the default browser which has an isolated profile and user data directory. final static PulsarSettings.CompanionwithDefaultBrowser()Use the default browser which has an isolated profile and user data directory. final static PulsarSettings.CompanionwithDefaultBrowser(BrowserType browserType, MutableConfig conf)Use the default browser which has an isolated profile and user data directory. final static PulsarSettings.CompanionwithDefaultBrowser(BrowserType browserType)Use the default browser which has an isolated profile and user data directory. final static PulsarSettings.CompanionwithPrototypeBrowser(MutableConfig conf)Use Google Chrome with the prototype environment. final static PulsarSettings.CompanionwithPrototypeBrowser()Use Google Chrome with the prototype environment. final static PulsarSettings.CompanionwithPrototypeBrowser(BrowserType browserType, MutableConfig conf)Use the specified browser with the prototype environment. final static PulsarSettings.CompanionwithPrototypeBrowser(BrowserType browserType)Use the specified browser with the prototype environment. final static PulsarSettings.CompanionwithSequentialBrowsers(MutableConfig conf)Use sequential browsers that inherits the prototype browser’s environment. final static PulsarSettings.CompanionwithSequentialBrowsers()Use sequential browsers that inherits the prototype browser’s environment. final static PulsarSettings.CompanionwithSequentialBrowsers(BrowserType browserType, MutableConfig conf)Use sequential browsers that inherits the prototype browser’s environment. final static PulsarSettings.CompanionwithSequentialBrowsers(BrowserType browserType)Use sequential browsers that inherits the prototype browser’s environment. final static PulsarSettings.CompanionwithSequentialBrowsers(BrowserType browserType, Integer maxAgents, MutableConfig conf)Use sequential browsers that inherits from the prototype browser’s environment. final static PulsarSettings.CompanionwithSequentialBrowsers(BrowserType browserType, Integer maxAgents)Use sequential browsers that inherits from the prototype browser’s environment. final static PulsarSettings.CompanionwithTemporaryBrowser(MutableConfig conf)Use a temporary browser that inherits from the prototype browser’s environment. final static PulsarSettings.CompanionwithTemporaryBrowser()Use a temporary browser that inherits from the prototype browser’s environment. final static PulsarSettings.CompanionwithTemporaryBrowser(BrowserType browserType, MutableConfig conf)Use a temporary browser that inherits from the prototype browser’s environment. final static PulsarSettings.CompanionwithTemporaryBrowser(BrowserType browserType)Use a temporary browser that inherits from the prototype browser’s environment. final static PulsarSettings.CompanionwithGUI(MutableConfig conf)Launch the browser in GUI mode. final static PulsarSettings.CompanionwithGUI()Launch the browser in GUI mode. final static PulsarSettings.Companionheaded(MutableConfig conf)Launch the browser in GUI mode. final static PulsarSettings.Companionheaded()Launch the browser in GUI mode. final static PulsarSettings.Companionheadless(MutableConfig conf)Launch the browser in headless mode. final static PulsarSettings.Companionheadless()Launch the browser in headless mode. final static PulsarSettings.Companionsupervised(MutableConfig conf)Launch the browser in supervised mode. final static PulsarSettings.Companionsupervised()Launch the browser in supervised mode. final static PulsarSettings.CompanionmaxBrowserContexts(Integer n, MutableConfig conf)Set the max number of agents final static PulsarSettings.CompanionmaxBrowserContexts(Integer n)Set the max number of agents final static PulsarSettings.CompanionmaxOpenTabs(Integer n, MutableConfig conf)Set the max number to open tabs in each browser context final static PulsarSettings.CompanionmaxOpenTabs(Integer n)Set the max number to open tabs in each browser context final static PulsarSettings.CompanionwithSPA(MutableConfig conf)Tell the system to work with single page application. final static PulsarSettings.CompanionwithSPA()Tell the system to work with single page application. final static PulsarSettings.CompanionwithSinglePageApplication(MutableConfig conf)Tell the system to work with single page application. final static PulsarSettings.CompanionwithSinglePageApplication()Tell the system to work with single page application. final static PulsarSettings.CompanionwithInteractLevel(InteractLevel level, MutableConfig conf)Defines the level of interaction with a webpage during crawling. final static PulsarSettings.CompanionwithInteractLevel(InteractLevel level)Defines the level of interaction with a webpage during crawling. final static PulsarSettings.CompanionwithInteractSettings(InteractSettings settings, MutableConfig conf)Use the specified interact settings to interact with webpages. final static PulsarSettings.CompanionwithInteractSettings(InteractSettings settings)Use the specified interact settings to interact with webpages. final static PulsarSettings.CompanionwithLLM(String provider, String name, String apiKey)Sets the Large Language Model (LLM) provider for the Browser4 settings. final static PulsarSettings.CompanionwithLLMProvider(String provider)Sets the Large Language Model (LLM) provider for the Browser4 settings. final static PulsarSettings.CompanionwithLLMName(String name)Sets the Large Language Model (LLM) name for the Browser4 settings. final static PulsarSettings.CompanionwithLLMAPIKey(String key)Sets the Large Language Model (LLM) API key for the Browser4 settings. -
-
Method Detail
-
getDisplayMode
final DisplayMode getDisplayMode()
-
getMaxBrowsers
final Integer getMaxBrowsers()
-
getMaxOpenTabs
final Integer getMaxOpenTabs()
-
getInteractSettings
final InteractSettings getInteractSettings()
-
getProfileMode
final BrowserProfileMode getProfileMode()
-
overrideSystemProperties
final Unit overrideSystemProperties()
-
overrideConfiguration
final Unit overrideConfiguration(MutableConfig conf)
-
withBrowserContextMode
@JvmOverloads() final static PulsarSettings.Companion withBrowserContextMode(BrowserProfileMode contextMode, MutableConfig conf)
-
withBrowserContextMode
@JvmOverloads() final static PulsarSettings.Companion withBrowserContextMode(BrowserProfileMode contextMode)
-
withBrowserContextMode
@JvmOverloads() final static PulsarSettings.Companion withBrowserContextMode(BrowserProfileMode contextMode, BrowserType browserType, MutableConfig conf)
-
withBrowserContextMode
@JvmOverloads() final static PulsarSettings.Companion withBrowserContextMode(BrowserProfileMode contextMode, BrowserType browserType)
-
withBrowser
@JvmOverloads() final static PulsarSettings.Companion withBrowser(BrowserType browserType, MutableConfig conf)
-
withBrowser
@JvmOverloads() final static PulsarSettings.Companion withBrowser(BrowserType browserType)
-
withSystemDefaultBrowser
@JvmOverloads() final static PulsarSettings.Companion withSystemDefaultBrowser(MutableConfig conf)
Use the system's default Chrome browser, so Browser4 visits websites just like you do. Any change to the browser will be kept.
No longer supported by Chrome since v143. See https://github.com/platonai/Browser4/issues/162
-
withSystemDefaultBrowser
@JvmOverloads() final static PulsarSettings.Companion withSystemDefaultBrowser()
Use the system's default Chrome browser, so Browser4 visits websites just like you do. Any change to the browser will be kept.
No longer supported by Chrome since v143. See https://github.com/platonai/Browser4/issues/162
-
withSystemDefaultBrowser
@JvmOverloads() final static PulsarSettings.Companion withSystemDefaultBrowser(BrowserType browserType, MutableConfig conf)
Use the system's default browser with the given type, so Browser4 visits websites just like you do. Any change to the browser will be kept.
No longer supported by Chrome since v143. See https://github.com/platonai/Browser4/issues/162
-
withSystemDefaultBrowser
@JvmOverloads() final static PulsarSettings.Companion withSystemDefaultBrowser(BrowserType browserType)
Use the system's default browser with the given type, so Browser4 visits websites just like you do. Any change to the browser will be kept.
No longer supported by Chrome since v143. See https://github.com/platonai/Browser4/issues/162
-
withDefaultBrowser
@JvmOverloads() final static PulsarSettings.Companion withDefaultBrowser(MutableConfig conf)
Use the default browser which has an isolated profile and user data directory. Any modifications made to the browser will be preserved, including the cookies, history, etc.
-
withDefaultBrowser
@JvmOverloads() final static PulsarSettings.Companion withDefaultBrowser()
Use the default browser which has an isolated profile and user data directory. Any modifications made to the browser will be preserved, including the cookies, history, etc.
-
withDefaultBrowser
@JvmOverloads() final static PulsarSettings.Companion withDefaultBrowser(BrowserType browserType, MutableConfig conf)
Use the default browser which has an isolated profile and user data directory. Any modifications made to the browser will be preserved, including the cookies, history, etc.
-
withDefaultBrowser
@JvmOverloads() final static PulsarSettings.Companion withDefaultBrowser(BrowserType browserType)
Use the default browser which has an isolated profile and user data directory. Any modifications made to the browser will be preserved, including the cookies, history, etc.
-
withPrototypeBrowser
@JvmOverloads() final static PulsarSettings.Companion withPrototypeBrowser(MutableConfig conf)
Use Google Chrome with the prototype environment. Any modifications made to the browser will be preserved. Sequential and temporary browsers will inherit the environment from the prototype browser.
-
withPrototypeBrowser
@JvmOverloads() final static PulsarSettings.Companion withPrototypeBrowser()
Use Google Chrome with the prototype environment. Any modifications made to the browser will be preserved. Sequential and temporary browsers will inherit the environment from the prototype browser.
-
withPrototypeBrowser
@JvmOverloads() final static PulsarSettings.Companion withPrototypeBrowser(BrowserType browserType, MutableConfig conf)
Use the specified browser with the prototype environment. Any modifications made to the browser will be preserved. Sequential and temporary browsers will inherit the environment from the prototype browser.
-
withPrototypeBrowser
@JvmOverloads() final static PulsarSettings.Companion withPrototypeBrowser(BrowserType browserType)
Use the specified browser with the prototype environment. Any modifications made to the browser will be preserved. Sequential and temporary browsers will inherit the environment from the prototype browser.
-
withSequentialBrowsers
@JvmOverloads() final static PulsarSettings.Companion withSequentialBrowsers(MutableConfig conf)
Use sequential browsers that inherits the prototype browser’s environment. The sequential browsers are permanent unless the context directories are deleted manually.
- Returns:
the PulsarSettings itself
-
withSequentialBrowsers
@JvmOverloads() final static PulsarSettings.Companion withSequentialBrowsers()
Use sequential browsers that inherits the prototype browser’s environment. The sequential browsers are permanent unless the context directories are deleted manually.
- Returns:
the PulsarSettings itself
-
withSequentialBrowsers
@JvmOverloads() final static PulsarSettings.Companion withSequentialBrowsers(BrowserType browserType, MutableConfig conf)
Use sequential browsers that inherits the prototype browser’s environment. The sequential browsers are permanent unless the context directories are deleted manually.
- Returns:
the PulsarSettings itself
-
withSequentialBrowsers
@JvmOverloads() final static PulsarSettings.Companion withSequentialBrowsers(BrowserType browserType)
Use sequential browsers that inherits the prototype browser’s environment. The sequential browsers are permanent unless the context directories are deleted manually.
- Returns:
the PulsarSettings itself
-
withSequentialBrowsers
@JvmOverloads() final static PulsarSettings.Companion withSequentialBrowsers(BrowserType browserType, Integer maxAgents, MutableConfig conf)
Use sequential browsers that inherits from the prototype browser’s environment. The sequential browsers are permanent unless the context directories are deleted manually.
- Parameters:
maxAgents- The maximum number of sequential privacy agents, the active privacy contexts is chosen from them.- Returns:
the PulsarSettings itself
-
withSequentialBrowsers
@JvmOverloads() final static PulsarSettings.Companion withSequentialBrowsers(BrowserType browserType, Integer maxAgents)
Use sequential browsers that inherits from the prototype browser’s environment. The sequential browsers are permanent unless the context directories are deleted manually.
- Parameters:
maxAgents- The maximum number of sequential privacy agents, the active privacy contexts is chosen from them.- Returns:
the PulsarSettings itself
-
withTemporaryBrowser
@JvmOverloads() final static PulsarSettings.Companion withTemporaryBrowser(MutableConfig conf)
Use a temporary browser that inherits from the prototype browser’s environment. The temporary browser will not be used again after it is shut down.
-
withTemporaryBrowser
@JvmOverloads() final static PulsarSettings.Companion withTemporaryBrowser()
Use a temporary browser that inherits from the prototype browser’s environment. The temporary browser will not be used again after it is shut down.
-
withTemporaryBrowser
@JvmOverloads() final static PulsarSettings.Companion withTemporaryBrowser(BrowserType browserType, MutableConfig conf)
Use a temporary browser that inherits from the prototype browser’s environment. The temporary browser will not be used again after it is shut down.
-
withTemporaryBrowser
@JvmOverloads() final static PulsarSettings.Companion withTemporaryBrowser(BrowserType browserType)
Use a temporary browser that inherits from the prototype browser’s environment. The temporary browser will not be used again after it is shut down.
-
withGUI
@JvmOverloads() final static PulsarSettings.Companion withGUI(MutableConfig conf)
Launch the browser in GUI mode.
-
withGUI
@JvmOverloads() final static PulsarSettings.Companion withGUI()
Launch the browser in GUI mode.
-
headed
@JvmOverloads() final static PulsarSettings.Companion headed(MutableConfig conf)
Launch the browser in GUI mode.
-
headed
@JvmOverloads() final static PulsarSettings.Companion headed()
Launch the browser in GUI mode.
-
headless
@JvmOverloads() final static PulsarSettings.Companion headless(MutableConfig conf)
Launch the browser in headless mode.
-
headless
@JvmOverloads() final static PulsarSettings.Companion headless()
Launch the browser in headless mode.
-
supervised
@JvmOverloads() final static PulsarSettings.Companion supervised(MutableConfig conf)
Launch the browser in supervised mode.
-
supervised
@JvmOverloads() final static PulsarSettings.Companion supervised()
Launch the browser in supervised mode.
-
maxBrowserContexts
@JvmOverloads() final static PulsarSettings.Companion maxBrowserContexts(Integer n, MutableConfig conf)
Set the max number of agents
-
maxBrowserContexts
@JvmOverloads() final static PulsarSettings.Companion maxBrowserContexts(Integer n)
Set the max number of agents
-
maxOpenTabs
@JvmOverloads() final static PulsarSettings.Companion maxOpenTabs(Integer n, MutableConfig conf)
Set the max number to open tabs in each browser context
-
maxOpenTabs
@JvmOverloads() final static PulsarSettings.Companion maxOpenTabs(Integer n)
Set the max number to open tabs in each browser context
-
withSPA
@JvmOverloads() final static PulsarSettings.Companion withSPA(MutableConfig conf)
Tell the system to work with single page application. To collect SPA data, the execution needs to have no timeout limit.
-
withSPA
@JvmOverloads() final static PulsarSettings.Companion withSPA()
Tell the system to work with single page application. To collect SPA data, the execution needs to have no timeout limit.
-
withSinglePageApplication
@JvmOverloads() final static PulsarSettings.Companion withSinglePageApplication(MutableConfig conf)
Tell the system to work with single page application. To collect SPA data, the execution needs to have no timeout limit.
-
withSinglePageApplication
@JvmOverloads() final static PulsarSettings.Companion withSinglePageApplication()
Tell the system to work with single page application. To collect SPA data, the execution needs to have no timeout limit.
-
withInteractLevel
@JvmOverloads() final static PulsarSettings.Companion withInteractLevel(InteractLevel level, MutableConfig conf)
Defines the level of interaction with a webpage during crawling.
Higher levels involve more interaction (e.g., scrolling, clicking), which may improve content extraction quality at the cost of speed.
-
withInteractLevel
@JvmOverloads() final static PulsarSettings.Companion withInteractLevel(InteractLevel level)
Defines the level of interaction with a webpage during crawling.
Higher levels involve more interaction (e.g., scrolling, clicking), which may improve content extraction quality at the cost of speed.
-
withInteractSettings
@JvmOverloads() final static PulsarSettings.Companion withInteractSettings(InteractSettings settings, MutableConfig conf)
Use the specified interact settings to interact with webpages.
-
withInteractSettings
@JvmOverloads() final static PulsarSettings.Companion withInteractSettings(InteractSettings settings)
Use the specified interact settings to interact with webpages.
-
withLLM
final static PulsarSettings.Companion withLLM(String provider, String name, String apiKey)
Sets the Large Language Model (LLM) provider for the Browser4 settings.
This function allows specifying the LLM provider to be used. The provider must be a non-null string.
Supported LLM providers include:
<a href='https://www.volcengine.com/docs/82379/1399008'>Volcengine API</a>
<a href='https://api-docs.deepseek.com/'>DeepSeek API</a>
For example, you can use the following code to set the LLM provider:
// use volcengine as the LLM provider PulsarSettings.withLLM("volcengine", "ep-20250218132011-2scs8", apiKey)- Parameters:
provider- The name of the LLM provider to be used.- Returns:
The current instance of PulsarSettings to allow method chaining.
-
withLLMProvider
final static PulsarSettings.Companion withLLMProvider(String provider)
Sets the Large Language Model (LLM) provider for the Browser4 settings.
This function allows specifying the LLM provider to be used. The provider must be a non-null string.
Supported LLM providers include:
<a href='https://www.volcengine.com/docs/82379/1399008'>Volcengine API</a>
<a href='https://api-docs.deepseek.com/'>DeepSeek API</a>
For example, you can use the following code to set the LLM provider:
PulsarSettings .withLLMProvider("volcengine") // use volcengine as the LLM provider .withLLMName("ep-20250218132011-2scs8") // the LLM name, you should change it to your own .withLLMAPIKey(apiKey) // the LLM api key, you should change it to your own- Parameters:
provider- The name of the LLM provider to be used.- Returns:
The current instance of PulsarSettings to allow method chaining.
-
withLLMName
final static PulsarSettings.Companion withLLMName(String name)
Sets the Large Language Model (LLM) name for the Browser4 settings.
Supported LLM providers include:
<a href='https://www.volcengine.com/docs/82379/1399008'>Volcengine API</a>
<a href='https://api-docs.deepseek.com/'>DeepSeek API</a>
For example, you can use the following code to set the LLM provider:
PulsarSettings .withLLMProvider("volcengine") // use volcengine as the LLM provider .withLLMName("ep-20250218132011-2scs8") // the LLM name, you should change it to your own .withLLMAPIKey(apiKey) // the LLM api key, you should change it to your own- Parameters:
name- The name of the Large Language Model (LLM) to be set.- Returns:
The current instance of PulsarSettings to allow for method chaining.
-
withLLMAPIKey
final static PulsarSettings.Companion withLLMAPIKey(String key)
Sets the Large Language Model (LLM) API key for the Browser4 settings.
Supported LLM providers include:
<a href='https://www.volcengine.com/docs/82379/1399008'>Volcengine API</a>
<a href='https://api-docs.deepseek.com/'>DeepSeek API</a>
For example, you can use the following code to set the LLM provider:
PulsarSettings .withLLMProvider("volcengine") // use volcengine as the LLM provider .withLLMName("ep-20250218132011-2scs8") // the LLM name, you should change it to your own .withLLMAPIKey(apiKey) // the LLM api key, you should change it to your own- Parameters:
key- The API key to be set.- Returns:
The current instance of PulsarSettings to allow for method chaining.
-
-
-
-