import asyncio
from browser_use_sdk import AsyncBrowserUse
from pydantic import BaseModel
class Site(BaseModel):
name: str
description: str
top_headline: str
urls = [
"https://news.ycombinator.com",
"https://reddit.com/r/technology",
"https://techcrunch.com",
]
async def extract(client, url):
return await client.run(
f"Get the name of the site, a one-sentence description, and the top headline from {url}",
output_schema=Site,
)
async def main():
client = AsyncBrowserUse()
results = await asyncio.gather(*[extract(client, url) for url in urls])
for r in results:
print(r.output)
asyncio.run(main())
import { BrowserUse } from "browser-use-sdk";
import { z } from "zod";
const Site = z.object({ name: z.string(), description: z.string(), topHeadline: z.string() });
const urls = [
"https://news.ycombinator.com",
"https://reddit.com/r/technology",
"https://techcrunch.com",
];
const client = new BrowserUse();
const results = await Promise.all(
urls.map((url) =>
client.run(
`Get the name of the site, a one-sentence description, and the top headline from ${url}`,
{ schema: Site },
),
),
);
results.forEach((r) => console.log(r.output));
Each
run() call automatically creates its own session. There is no need to manage sessions manually for independent tasks.