Anchor Browser delivers a state-of-the-art 89% Score on the industry-standard benchmark WebVoyager, leveraging browser-use as a core component of the automation capability.
import{ chromium }from"playwright-core";const browserSession =await chromium.connectOverCDP(`wss://connect.anchorbrowser.io?apiKey=ANCHOR-API-KEY`);const context = browser.contexts()[0];const ai = context.serviceWorkers()[0];const page = context.pages()[0];// Combine regular playwright and AI actions to benefit from both optionsawait page.goto("http://docs.anchorbrowser.io/",{waitUntil:'domcontentloaded'});// Use the embedded 'ai' objectconst result =await ai.evaluate('Find the last game played by Milwaukee in the NBA and return the result')console.log(result);
The AI object can also be used to extract structured data from the browser. This is done by providing a JSON schema to the AI object, which will then return the structured data.
The following demonstrates using Zod and Pydantic to utilize the structured output capability.
import{ chromium }from'playwright';import{ z }from"zod";import{ zodToJsonSchema }from"zod-to-json-schema";const browser =await chromium.connectOverCDP("wss://connect.anchorbrowser.io?apiKey=ANCHOR-API-KEY");const context = browser.contexts()[0];const ai = context.serviceWorkers()[0];const page = context.pages()[0];const outputSchema = z.object({ nodes_cpu_usage: z.array( z.object({ node: z.string(), cluster: z.string(), cpu_avg_percentage: z.number(),}))});const jsonSchema =zodToJsonSchema(outputSchema);const taskPayload ={ output_schema: jsonSchema, prompt:'Collect the node names and their CPU average %',};await page.goto("https://play.grafana.org/a/grafana-k8s-app/navigation/nodes?from=now-1h&to=now&refresh=1m");const result =await ai.evaluate(JSON.stringify(taskPayload));console.info(result);