Class PulsarSettings

  • All Implemented Interfaces:

    
    public final class PulsarSettings
    
                        

    The 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

    • Constructor Detail

      • PulsarSettings

        PulsarSettings(Boolean spa, DisplayMode displayMode, Integer maxBrowsers, Integer maxOpenTabs, InteractSettings interactSettings, BrowserProfileMode profileMode, String label)
    • Method Detail

      • 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(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 browser profiles, 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 browser profiles, the active privacy contexts is chosen from them.
        Returns:

        the PulsarSettings itself

      • 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.

      • 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.

      • 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.