Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions src/content/cloud-offer/tools/cdp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Use Lightpanda CDP with [Playwright](https://playwright.dev/).


```js copy
import playwright from "playwright";
import playwright from "playwright-core";

const browser = await playwright.chromium.connectOverCDP(
"wss://euwest.cloud.lightpanda.io/ws?token=TOKEN",
Expand All @@ -86,20 +86,21 @@ More examples in [demo/playwright](https://github.com/lightpanda-io/demo/tree/ma
Use Lightpanda CDP with [Puppeteer](https://pptr.dev/).

```js copy
import playwright from "playwright";
import puppeteer from 'puppeteer-core';

const browser = await playwright.chromium.connectOverCDP(
"wss://euwest.cloud.lightpanda.io/ws?token=TOKEN",
);
const context = await browser.newContext();
const browser = await puppeteer.connect({
browserWSEndpoint: "wss://euwest.cloud.lightpanda.io/ws?token=TOKEN",
});
const context = await browser.createBrowserContext();
const page = await context.newPage();

//...
// ...

await page.close();
await context.close();
await browser.disconnect();
```

More examples in [demo/puppeteer](https://github.com/lightpanda-io/demo/tree/main/puppeteer).

### Chromedp
Expand All @@ -110,31 +111,30 @@ Use Lightpanda CDP with [Chromedp](https://github.com/chromedp/chromedp).
package main

import (
"context"
"flag"
"log"
"context"
"log"

"github.com/chromedp/chromedp"
"github.com/chromedp/chromedp"
)

func main() {
ctx, cancel = chromedp.NewRemoteAllocator(ctx,
"wss://euwest.cloud.lightpanda.io/ws?token=TOKEN", chromedp.NoModifyURL,
)
defer cancel()

ctx, cancel := chromedp.NewContext(allocatorContext)
defer cancel()

var title string
if err := chromedp.Run(ctx,
chromedp.Navigate("https://lightpanda.io"),
chromedp.Title(&title),
); err != nil {
log.Fatalf("Failed getting title of lightpanda.io: %v", err)
}

log.Println("Got title of:", title)
ctx, cancel := chromedp.NewRemoteAllocator(context.Background(),
"wss://euwest.cloud.lightpanda.io/ws?token=TOKEN", chromedp.NoModifyURL,
)
defer cancel()

ctx, cancel = chromedp.NewContext(ctx)
defer cancel()

var title string
if err := chromedp.Run(ctx,
chromedp.Navigate("https://lightpanda.io"),
chromedp.Title(&title),
); err != nil {
log.Fatalf("Failed getting title of lightpanda.io: %v", err)
}

log.Println("Got title of:", title)
}
```
More examples in [demo/chromedp](https://github.com/lightpanda-io/demo/tree/main/chromedp).