SDK Quickstart
Run the demo with your preferred browser client. The first launch downloads Mimic automatically; later runs reuse it.
Local launch requires Windows x64 or Linux x64; see the runtime requirements. On another client platform, connect to a supported host through an endpoint you can access.
Install
Requires Node.js 22.19 or later, and npm.
npm install mimic-browserAdd Playwright if it is not installed.
npm install playwright-core@1.63.0Create files
import { launch } from "mimic-browser/playwright";
// Optional runtime pin: launch({ runtimeVersion: "0.2.4" })
const session = await launch();
try {
const context = await session.newContext();
const page = await context.newPage();
await page.goto("https://example.com");
console.log(await page.title());
} finally {
await session.close();
}Run
node launch.mjsExample DomainStart Mimic on http://127.0.0.1:9222 first. Closing this session disconnects and leaves that runtime running.
Create files
import { connect } from "mimic-browser/playwright";
const session = await connect("http://127.0.0.1:9222");
try {
const context = await session.newContext();
const page = await context.newPage();
await page.goto("https://example.com");
console.log(await page.title());
} finally {
await session.close();
}Run
node connect.mjsExample DomainInstall
Requires Node.js 22.19 or later, and npm.
npm install mimic-browserAdd Puppeteer if it is not installed.
npm install puppeteer-core@25.10.0Create files
import { launch } from "mimic-browser/puppeteer";
// Optional runtime pin: launch({ runtimeVersion: "0.2.4" })
const session = await launch();
try {
const context = await session.newContext();
const page = await context.newPage();
await page.goto("https://example.com");
console.log(await page.title());
} finally {
await session.close();
}Run
node launch.mjsExample DomainStart Mimic on http://127.0.0.1:9222 first. Closing this session disconnects and leaves that runtime running.
Create files
import { connect } from "mimic-browser/puppeteer";
const session = await connect("http://127.0.0.1:9222");
try {
const context = await session.newContext();
const page = await context.newPage();
await page.goto("https://example.com");
console.log(await page.title());
} finally {
await session.close();
}Run
node connect.mjsExample DomainInstall
Requires Node.js 22.19 or later, and npm.
npm install mimic-browser
npm install --save-dev typescript tsx @types/node@22Add Playwright if it is not installed.
npm install playwright-core@1.63.0Create files
async function main() {
const { launch } = await import("mimic-browser/playwright");
// Optional runtime pin: launch({ runtimeVersion: "0.2.4" })
const session = await launch();
try {
const context = await session.newContext();
const page = await context.newPage();
await page.goto("https://example.com");
console.log(await page.title());
} finally {
await session.close();
}
}
main().catch(error => {
console.error(error);
process.exitCode = 1;
});Run
npx tsx launch.tsExample DomainStart Mimic on http://127.0.0.1:9222 first. Closing this session disconnects and leaves that runtime running.
Create files
async function main() {
const { connect } = await import("mimic-browser/playwright");
const session = await connect("http://127.0.0.1:9222");
try {
const context = await session.newContext();
const page = await context.newPage();
await page.goto("https://example.com");
console.log(await page.title());
} finally {
await session.close();
}
}
main().catch(error => {
console.error(error);
process.exitCode = 1;
});Run
npx tsx connect.tsExample DomainInstall
Requires Node.js 22.19 or later, and npm.
npm install mimic-browser
npm install --save-dev typescript tsx @types/node@22Add Puppeteer if it is not installed.
npm install puppeteer-core@25.10.0Create files
async function main() {
const { launch } = await import("mimic-browser/puppeteer");
// Optional runtime pin: launch({ runtimeVersion: "0.2.4" })
const session = await launch();
try {
const context = await session.newContext();
const page = await context.newPage();
await page.goto("https://example.com");
console.log(await page.title());
} finally {
await session.close();
}
}
main().catch(error => {
console.error(error);
process.exitCode = 1;
});Run
npx tsx launch.tsExample DomainStart Mimic on http://127.0.0.1:9222 first. Closing this session disconnects and leaves that runtime running.
Create files
async function main() {
const { connect } = await import("mimic-browser/puppeteer");
const session = await connect("http://127.0.0.1:9222");
try {
const context = await session.newContext();
const page = await context.newPage();
await page.goto("https://example.com");
console.log(await page.title());
} finally {
await session.close();
}
}
main().catch(error => {
console.error(error);
process.exitCode = 1;
});Run
npx tsx connect.tsExample DomainInstall
Requires Python 3.10 or later with pip and venv. Keep the virtual environment active for the remaining commands.
python3 -m venv .venv
source .venv/bin/activate
python -m pip install mimic-browserWindows · PowerShell
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install mimic-browserWindows · Command Prompt
python -m venv .venv
.venv\Scripts\activate.bat
python -m pip install mimic-browserAdd Playwright · sync if it is not installed.
python -m pip install playwright==1.63.0Create files
from mimic.playwright.sync_api import launch
# Optional runtime pin: launch(runtime_version="0.2.4")
with launch() as session:
context = session.new_context()
page = context.new_page()
page.goto("https://example.com")
print(page.title())Run
python launch.pyExample DomainStart Mimic on http://127.0.0.1:9222 first. Closing this session disconnects and leaves that runtime running.
Create files
from mimic.playwright.sync_api import connect
with connect("http://127.0.0.1:9222") as session:
context = session.new_context()
page = context.new_page()
page.goto("https://example.com")
print(page.title())Run
python connect.pyExample DomainInstall
Requires Python 3.10 or later with pip and venv. Keep the virtual environment active for the remaining commands.
python3 -m venv .venv
source .venv/bin/activate
python -m pip install mimic-browserWindows · PowerShell
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install mimic-browserWindows · Command Prompt
python -m venv .venv
.venv\Scripts\activate.bat
python -m pip install mimic-browserAdd Playwright · async if it is not installed.
python -m pip install playwright==1.63.0Create files
import asyncio
from mimic.playwright.async_api import launch
async def main():
# Optional runtime pin: launch(runtime_version="0.2.4")
async with await launch() as session:
context = await session.new_context()
page = await context.new_page()
await page.goto("https://example.com")
print(await page.title())
asyncio.run(main())Run
python launch.pyExample DomainStart Mimic on http://127.0.0.1:9222 first. Closing this session disconnects and leaves that runtime running.
Create files
import asyncio
from mimic.playwright.async_api import connect
async def main():
async with await connect("http://127.0.0.1:9222") as session:
context = await session.new_context()
page = await context.new_page()
await page.goto("https://example.com")
print(await page.title())
asyncio.run(main())Run
python connect.pyExample DomainInstall
Requires Python 3.10 or later with pip and venv. Keep the virtual environment active for the remaining commands.
python3 -m venv .venv
source .venv/bin/activate
python -m pip install mimic-browserWindows · PowerShell
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install mimic-browserWindows · Command Prompt
python -m venv .venv
.venv\Scripts\activate.bat
python -m pip install mimic-browserAdd Pyppeteer if it is not installed.
python -m pip install pyppeteer==2.0.0Create files
import asyncio
from mimic.pyppeteer import launch
async def main():
# Optional runtime pin: launch(runtime_version="0.2.4")
async with await launch() as session:
context = await session.new_context()
page = await context.newPage()
await page.goto("https://example.com")
print(await page.title())
asyncio.run(main())Run
python launch.pyExample DomainStart Mimic on http://127.0.0.1:9222 first. Closing this session disconnects and leaves that runtime running.
Create files
import asyncio
from mimic.pyppeteer import connect
async def main():
async with await connect("http://127.0.0.1:9222") as session:
context = await session.new_context()
page = await context.newPage()
await page.goto("https://example.com")
print(await page.title())
asyncio.run(main())Run
python connect.pyExample DomainInstall
Requires the .NET 8 SDK or later.
dotnet new console -n MimicDemo --framework net8.0
cd MimicDemo
dotnet add package mimic-browser.Playwright --version 0.1.1Create files
using Mimic.Playwright;
using Mimic.Sdk;
// Optional runtime pin: PlaywrightSession.LaunchAsync(new RuntimeOptions { Version = "0.2.4" })
await using var session = await PlaywrightSession.LaunchAsync();
var context = await session.NewContextAsync();
var page = await context.NewPageAsync();
await page.GotoAsync("https://example.com");
Console.WriteLine(await page.TitleAsync());Run
dotnet runExample DomainConnects to Mimic already listening at http://127.0.0.1:9222. Closing this session preserves the external runtime.
Create files
using Mimic.Playwright;
using Mimic.Sdk;
await using var session = await PlaywrightSession.ConnectAsync("http://127.0.0.1:9222");
var context = await session.NewContextAsync();
var page = await context.NewPageAsync();
await page.GotoAsync("https://example.com");
Console.WriteLine(await page.TitleAsync());Run
dotnet runExample DomainInstall
Requires the .NET 8 SDK or later.
dotnet new console -n MimicDemo --framework net8.0
cd MimicDemo
dotnet add package mimic-browser.PuppeteerSharp --version 0.1.1Create files
using Mimic.PuppeteerSharp;
using Mimic.Sdk;
// Optional runtime pin: PuppeteerSession.LaunchAsync(new RuntimeOptions { Version = "0.2.4" })
await using var session = await PuppeteerSession.LaunchAsync();
var context = await session.NewContextAsync();
var page = await context.NewPageAsync();
await page.GoToAsync("https://example.com");
Console.WriteLine(await page.GetTitleAsync());Run
dotnet runExample DomainConnects to Mimic already listening at http://127.0.0.1:9222. Closing this session preserves the external runtime.
Create files
using Mimic.PuppeteerSharp;
using Mimic.Sdk;
await using var session = await PuppeteerSession.ConnectAsync("http://127.0.0.1:9222");
var context = await session.NewContextAsync();
var page = await context.NewPageAsync();
await page.GoToAsync("https://example.com");
Console.WriteLine(await page.GetTitleAsync());Run
dotnet runExample DomainInstall
Requires JDK 17 or later, and Maven.
mkdir mimic-java-demo
cd mimic-java-demo
mkdir src
mkdir src/main
mkdir src/main/javaCreate files
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>mimic-demo</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>boo.mimic</groupId>
<artifactId>mimic-browser</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.63.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.6.1</version>
<configuration><mainClass>Main</mainClass></configuration>
</plugin>
</plugins>
</build>
</project>import io.mimicbrowser.sdk.RuntimeOptions;
import io.mimicbrowser.sdk.playwright.PlaywrightSession;
public class Main {
public static void main(String[] args) {
// Optional runtime pin: PlaywrightSession.launch(new RuntimeOptions().version("0.2.4"))
try (var session = PlaywrightSession.launch(new RuntimeOptions())) {
var context = session.newContext();
var page = context.newPage();
page.navigate("https://example.com");
System.out.println(page.title());
}
}
}Run
mvn -q compile exec:javaExample DomainConnects to Mimic already listening at http://127.0.0.1:9222. Closing this session preserves the external runtime.
Create files
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>mimic-demo</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>boo.mimic</groupId>
<artifactId>mimic-browser</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.63.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.6.1</version>
<configuration><mainClass>Main</mainClass></configuration>
</plugin>
</plugins>
</build>
</project>import io.mimicbrowser.sdk.RuntimeOptions;
import io.mimicbrowser.sdk.playwright.PlaywrightSession;
public class Main {
public static void main(String[] args) {
try (var session = PlaywrightSession.connect("http://127.0.0.1:9222")) {
var context = session.newContext();
var page = context.newPage();
page.navigate("https://example.com");
System.out.println(page.title());
}
}
}Run
mvn -q compile exec:javaExample DomainInstall
Requires JDK 17 or later, and Maven. Maven installs the Kotlin compiler.
mkdir mimic-kotlin-demo
cd mimic-kotlin-demo
mkdir src
mkdir src/main
mkdir src/main/kotlinCreate files
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>mimic-kotlin-demo</artifactId>
<version>1.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>2.2.21</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>boo.mimic</groupId>
<artifactId>mimic-browser</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.63.0</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration><jvmTarget>17</jvmTarget></configuration>
<executions>
<execution>
<id>compile</id><phase>compile</phase>
<goals><goal>compile</goal></goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.6.1</version>
<configuration><mainClass>MainKt</mainClass></configuration>
</plugin>
</plugins>
</build>
</project>import io.mimicbrowser.sdk.RuntimeOptions
import io.mimicbrowser.sdk.playwright.PlaywrightSession
fun main() {
// Optional runtime pin: PlaywrightSession.launch(RuntimeOptions().version("0.2.4"))
PlaywrightSession.launch(RuntimeOptions()).use { session ->
val context = session.newContext()
val page = context.newPage()
page.navigate("https://example.com")
println(page.title())
}
}Run
mvn -q compile exec:javaExample DomainConnects to Mimic already listening at http://127.0.0.1:9222. Closing this session preserves the external runtime.
Create files
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>mimic-kotlin-demo</artifactId>
<version>1.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>2.2.21</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>boo.mimic</groupId>
<artifactId>mimic-browser</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.63.0</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration><jvmTarget>17</jvmTarget></configuration>
<executions>
<execution>
<id>compile</id><phase>compile</phase>
<goals><goal>compile</goal></goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.6.1</version>
<configuration><mainClass>MainKt</mainClass></configuration>
</plugin>
</plugins>
</build>
</project>import io.mimicbrowser.sdk.RuntimeOptions
import io.mimicbrowser.sdk.playwright.PlaywrightSession
fun main() {
PlaywrightSession.connect("http://127.0.0.1:9222").use { session ->
val context = session.newContext()
val page = context.newPage()
page.navigate("https://example.com")
println(page.title())
}
}Run
mvn -q compile exec:javaExample DomainInstall
Requires Go 1.26 or later.
mkdir mimic-example
cd mimic-example
go mod init example.com/mimic-example
go get github.com/mimic-browser/sdk/go/rod@v0.1.1Add Rod if it is not installed.
go get github.com/go-rod/rod@v0.116.2Create files
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/go-rod/rod/lib/proto"
mimic "github.com/mimic-browser/sdk/go"
sdk "github.com/mimic-browser/sdk/go/rod"
)
func main() {
if err := run(); err != nil { log.Fatal(err) }
}
func run() error {
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
// Optional runtime pin: sdk.Launch(ctx, mimic.RuntimeOptions{Version: "0.2.4"})
session, err := sdk.Launch(ctx, mimic.RuntimeOptions{})
if err != nil { return err }
defer session.Close()
browser, err := session.NewContext(ctx, nil, nil)
if err != nil { return err }
page, err := browser.Page(proto.TargetCreateTarget{URL: "https://example.com"})
if err != nil { return err }
if err := page.WaitLoad(); err != nil { return err }
result, err := page.Eval("() => document.title")
if err != nil { return err }
fmt.Println(result.Value)
return nil
}
Run
go run .Example DomainStart Mimic on http://127.0.0.1:9222 before running this example. Closing the SDK session leaves that runtime running.
Create files
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/go-rod/rod/lib/proto"
sdk "github.com/mimic-browser/sdk/go/rod"
)
func main() {
if err := run(); err != nil { log.Fatal(err) }
}
func run() error {
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
session, err := sdk.Connect(ctx, "http://127.0.0.1:9222")
if err != nil { return err }
defer session.Close()
browser, err := session.NewContext(ctx, nil, nil)
if err != nil { return err }
page, err := browser.Page(proto.TargetCreateTarget{URL: "https://example.com"})
if err != nil { return err }
if err := page.WaitLoad(); err != nil { return err }
result, err := page.Eval("() => document.title")
if err != nil { return err }
fmt.Println(result.Value)
return nil
}
Run
go run .Example DomainInstall
Requires Go 1.26 or later.
mkdir mimic-example
cd mimic-example
go mod init example.com/mimic-example
go get github.com/mimic-browser/sdk/go/chromedp@v0.1.1Add chromedp if it is not installed.
go get github.com/chromedp/chromedp@v0.15.1Create files
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/chromedp/chromedp"
mimic "github.com/mimic-browser/sdk/go"
sdk "github.com/mimic-browser/sdk/go/chromedp"
)
func main() {
if err := run(); err != nil { log.Fatal(err) }
}
func run() error {
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
// Optional runtime pin: sdk.Launch(ctx, mimic.RuntimeOptions{Version: "0.2.4"})
session, err := sdk.Launch(ctx, mimic.RuntimeOptions{})
if err != nil { return err }
defer session.Close()
var title string
if err := chromedp.Run(session.Context,
chromedp.Navigate("https://example.com"),
chromedp.Title(&title),
); err != nil { return err }
fmt.Println(title)
return nil
}
Run
go run .Example DomainStart Mimic on http://127.0.0.1:9222 before running this example. Closing the SDK session leaves that runtime running.
Create files
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/chromedp/chromedp"
sdk "github.com/mimic-browser/sdk/go/chromedp"
)
func main() {
if err := run(); err != nil { log.Fatal(err) }
}
func run() error {
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
session, err := sdk.Connect(ctx, "http://127.0.0.1:9222")
if err != nil { return err }
defer session.Close()
var title string
if err := chromedp.Run(session.Context,
chromedp.Navigate("https://example.com"),
chromedp.Title(&title),
); err != nil { return err }
fmt.Println(title)
return nil
}
Run
go run .Example DomainInstall
Requires Rust 1.89 or later, Cargo, and your platform's native linker and build tools.
cargo new mimic-example
cd mimic-example
cargo add mimic-browser@0.1.1 --features chromiumoxide
cargo add serde_json@1
cargo add tokio@1 --features macros,rt-multi-threadAdd chromiumoxide if it is not installed.
cargo add chromiumoxide@0.9.1Create files
use mimic_browser::{chromiumoxide::Session, RuntimeOptions};
use mimic_browser::generated::{ConfigureContextParams};
use chromiumoxide::cdp::browser_protocol::target::CreateTargetParams;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Optional runtime pin: Session::launch(RuntimeOptions { version: Some("0.2.4".into()), ..Default::default() }).await?
let mut session = Session::launch(RuntimeOptions::default()).await?;
let result: Result<(), Box<dyn std::error::Error>> = async {
let context = session.new_context(ConfigureContextParams::default()).await?;
let page = session.browser.new_page(CreateTargetParams::builder()
.url("about:blank")
.browser_context_id(context)
.build()?
).await?;
page.goto("https://example.com").await?;
let title: String = page.evaluate("document.title").await?.into_value()?;
println!("{title}");
page.close().await?;
Ok(())
}.await;
let closed = session.close().await;
result?;
closed?;
Ok(())
}
Run
cargo runExample DomainStart Mimic on http://127.0.0.1:9222 before running this example. Closing the SDK session leaves that runtime running.
Create files
use mimic_browser::{chromiumoxide::Session};
use mimic_browser::generated::{ConfigureContextParams};
use chromiumoxide::cdp::browser_protocol::target::CreateTargetParams;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut session = Session::connect("http://127.0.0.1:9222").await?;
let result: Result<(), Box<dyn std::error::Error>> = async {
let context = session.new_context(ConfigureContextParams::default()).await?;
let page = session.browser.new_page(CreateTargetParams::builder()
.url("about:blank")
.browser_context_id(context)
.build()?
).await?;
page.goto("https://example.com").await?;
let title: String = page.evaluate("document.title").await?.into_value()?;
println!("{title}");
page.close().await?;
Ok(())
}.await;
let closed = session.close().await;
result?;
closed?;
Ok(())
}
Run
cargo runExample DomainInstall
Requires Ruby 3.2 or later, RubyGems, and native extension build tools.
gem install mimic-browser --version 0.1.1Add Ferrum if it is not installed.
gem install ferrum --version 0.18.0Create files
require "mimic_sdk/ferrum"
# Optional runtime pin: MimicSDK::Ferrum.launch(runtime_version: "0.2.4")
MimicSDK::Ferrum.launch do |session|
context = session.new_context
page = context.create_page
page.go_to("https://example.com")
puts page.title
end
Run
ruby scrape.rbExample DomainStart Mimic on http://127.0.0.1:9222 before running this example. Closing the SDK session leaves that runtime running.
Create files
require "mimic_sdk/ferrum"
MimicSDK::Ferrum.connect("http://127.0.0.1:9222") do |session|
context = session.new_context
page = context.create_page
page.go_to("https://example.com")
puts page.title
end
Run
ruby scrape.rbExample DomainInstall
Requires PHP 8.2 or later, Composer, and the curl, json, openssl, zlib, and zip extensions.
mkdir mimic-php-demo
cd mimic-php-demo
composer init --name=mimic/demo --no-interaction
composer require mimic-browser/sdk:0.1.1Add chrome-php if it is not installed.
composer require chrome-php/chrome:1.16.0Create files
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use Mimic\Sdk\Chrome\ChromeSession;
use Mimic\Sdk\RuntimeOptions;
// Optional runtime pin: ChromeSession::launch(new RuntimeOptions(version: '0.2.4'))
$session = ChromeSession::launch();
try {
$context = $session->newContext();
$page = $session->newPage($context);
$page->navigate('https://example.com')->waitForNavigation();
echo $page->evaluate('document.title')->getReturnValue(), PHP_EOL;
} finally {
$session->close();
}Run
php example.phpExample DomainConnects to Mimic already listening at http://127.0.0.1:9222. Closing this session preserves the external runtime.
Create files
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use Mimic\Sdk\Chrome\ChromeSession;
use Mimic\Sdk\RuntimeOptions;
$session = ChromeSession::connect('http://127.0.0.1:9222');
try {
$context = $session->newContext();
$page = $session->newPage($context);
$page->navigate('https://example.com')->waitForNavigation();
echo $page->evaluate('document.title')->getReturnValue(), PHP_EOL;
} finally {
$session->close();
}Run
php example.phpExample Domain