Open
The following example demonstrates how to request a browser instance, navigate to a webpage, and close the browser:
Full example
How It Works
Initialize the Client: Create an instance of
BrowserService
using your API tokeRequest a Browser Instance: Call
svc.Open()
to request a new browser session from the CloudBrowser.AI service.Connect with PuppeteerSharp: Use the WebSocket address provided in the response to connect to the browser instance using
Puppeteer.ConnectAsync()
.Perform Browser Actions: Interact with the browser via PuppeteerSharp, such as navigating to a webpage or automating tasks.
Close the Browser: Either use PuppeteerSharp's
browser.CloseAsync()
or CloudBrowser.AI'ssvc.Close()
API to terminate the session.
Open (with parameters)
The following example demonstrates how to request a browser instance with advanced configuration, including custom browser settings, proxy, and a timeout for keeping the browser open.
Label: Set a custom label for the browser instance.
Browser: Choose the browser type (e.g., Chromium or Chrome).
KeepOpen: Set the timeout in seconds for how long the browser should remain open without a Puppeteer connection.
Proxy: Configure proxy settings (host, port, username, password).
Full example
Last updated