Quick Start

Welcome and thanks for using Browseasy. Here in this Quick Start guide you'll find the quick instructions to work with Browseasy using popular libraries.

Make sure that you are already signed-in to see your endpoint and API key on My Products page.

You can also use our public example repository to follow this quick start guide.

 

Please check puppeteer to install and setup your first application.

It's sufficient to use puppeteer-core library with Browseasy, but you can also use regular puppeteer package.

$ npm i puppeteer-core
or
$ npm i puppeteer

If you are already using puppeteer, then you're ready to go. All you need to do is to connect to your Browseasy instance on the cloud, instead of running your browser locally.

import * as puppeteer from 'puppeteer-core';

// Update your endpoint with the one dedicated to your own plan or use freemium.
const BROWSEASY_ENDPOINT = 'wss://freemium.browseasy.com'; 

// Check your API key from My Products page for your plan and update accordingly. 
const BROWSEASY_API_KEY = 'YOUR-API-KEY';

// Your unique connection string.
const BROWSEASY_CONNECTION_STRING = `${BROWSEASY_ENDPOINT}?code=${BROWSEASY_API_KEY}`;

(async () => {
    // Run headless browser locally, no more.
    // const browser = await puppeteer.launch();

    // Run headless browser on the cloud.
    const browser = await puppeteer.connect({
        browserWSEndpoint: BROWSEASY_CONNECTION_STRING,
        // Always reset default viewport.
        // Browseasy will launch your browser with 1920x1080 resolution by default.
        defaultViewport: null
    });

    const page = await browser.newPage();
    await page.goto('https://browseasy.com');
    await page.screenshot({ path: 'browseasy.png' });

    await browser.close();
})();
 

Please check puppeteer-sharp to install and setup your first application.

using System.Threading.Tasks;
using PuppeteerSharp;

namespace screenshot
{
    class Program
    {
        // Update your endpoint with the one dedicated to your own plan or use freemium.
        static readonly string BROWSEASY_ENDPOINT = "wss://freemium.browseasy.com";

        // Check your API key from My Products page for your plan and update accordingly. 
        static readonly string BROWSEASY_API_KEY = "YOUR-API-KEY";

        // Your unique connection string.
        static readonly string BROWSEASY_CONNECTION_STRING = $"{BROWSEASY_ENDPOINT}?code={BROWSEASY_API_KEY}";

        public static async Task Main()
        {
            var options = new ConnectOptions()
            {
                BrowserWSEndpoint = BROWSEASY_CONNECTION_STRING,
                // Always reset default viewport.
                // Browseasy will launch your browser with 1920x1080 resolution by default.
                DefaultViewport = null
            };

            // Run headless browser on the cloud.
            using (var browser = await PuppeteerSharp.Puppeteer.ConnectAsync(options))
            {
                using (var page = await browser.NewPageAsync())
                {
                    await page.GoToAsync("https://browseasy.com");
                    await page.ScreenshotAsync("browseasy.png");
                }
            }
        }
    }
}
 

Please check playwright to install and setup your first application.

There are multiple programming languages supported by playwright. You can check the same example for other programming languages in our public example repository

import { chromium } from "playwright";

// Update your endpoint with the one dedicated to your own plan or use freemium.
const BROWSEASY_ENDPOINT = 'wss://freemium.browseasy.com'; 

// Check your API key from My Products page for your plan and update accordingly. 
const BROWSEASY_API_KEY = 'YOUR-API-KEY';

// Your unique connection string.
const BROWSEASY_CONNECTION_STRING = `${BROWSEASY_ENDPOINT}?code=${BROWSEASY_API_KEY}`;

(async () => {
    // Run headless browser locally, no more.
    // const browser = await chromium.launch();
    
    // Run headless browser on the cloud.
    const browser = await chromium.connectOverCDP({
        endpointURL: BROWSEASY_CONNECTION_STRING,
    });

    // Unfortunately, default context is always overwritten by playwright.

    // We need to create a new context, so that Browseasy can handle
    // screen resolution and viewport adjustment.
    const context = await browser.newContext({
        viewport: null
    });
    const page = await context.newPage();
    

    await page.goto('https://browseasy.com/');
    await page.screenshot({ path: 'browseasy.png' });

    await browser.close();
    
})();
    
 

Please check chromedp to install and setup your first application.

There are multiple programming languages supported by playwright. You can check the same example for other programming languages in our public example repository

package main

import (
	"context"
	"fmt"
	"io/ioutil"
	"log"

	"github.com/chromedp/chromedp"
)

// Update your endpoint with the one dedicated to your own plan or use freemium.
const BROWSEASY_ENDPOINT = "wss://freemium.browseasy.com"

// Check your API key from My Products page for your plan and update accordingly.
const BROWSEASY_API_KEY = "YOUR-API-KEY"

// Your unique connection string.
var BROWSEASY_CONNECTION_STRING = fmt.Sprintf("%s?code=%s", BROWSEASY_ENDPOINT, BROWSEASY_API_KEY)

func main() {
	// create allocator context for use with creating a browser context later
	allocatorContext, cancel := chromedp.NewRemoteAllocator(context.Background(), BROWSEASY_CONNECTION_STRING)
	defer cancel()

	// create context
	ctxt, cancel := chromedp.NewContext(allocatorContext)
	defer cancel()

	var buf []byte
	// capture a screenshot
	if err := chromedp.Run(ctxt,
		chromedp.Navigate("https://browseasy.com"),
		chromedp.CaptureScreenshot(&buf),
	); err != nil {
		log.Fatalf("Failed: %v", err)
	}
	if err := ioutil.WriteFile("browseasy.png", buf, 0o644); err != nil {
		log.Fatal(err)
	}
}