@@ -28,25 +28,28 @@ npm install @lightfeed/browser-agent
2828
2929Perfect for AWS Lambda and other serverless environments. Uses [ @sparticuz/chromium ] ( https://github.com/Sparticuz/chromium ) to run Chrome in serverless environments with minimal cold start times and memory usage.
3030
31+ > [ !IMPORTANT]
32+ > This project uses Playwright, which ships with a specific version of Chromium. You need to install the matching version of ` @sparticuz/chromium ` . For example, we are using [ Playwright 1.48] ( https://playwright.dev/docs/release-notes#version-148 ) (which supports Chromium 130), you should install ` @sparticuz/chromium@130 ` .
33+
3134``` typescript
32- import { BrowserAgent } from ' @lightfeed/browser-agent' ;
33- import chromium from ' @sparticuz/chromium' ;
34- import { AxiosProxyConfig } from ' axios' ;
35+ import { BrowserAgent } from " @lightfeed/browser-agent" ;
36+ import chromium from " @sparticuz/chromium" ;
37+ import { AxiosProxyConfig } from " axios" ;
3538
3639const agent = new BrowserAgent ({
37- browserProvider: ' Serverless' ,
40+ browserProvider: " Serverless" ,
3841 serverlessConfig: {
3942 executablePath: await chromium .executablePath (),
4043 options: {
4144 args: chromium .args ,
4245 },
4346 // Use proxy (optional)
4447 proxy: {
45- host: ' proxy.example.com' ,
48+ host: " proxy.example.com" ,
4649 port: 8080 ,
4750 auth: {
48- username: ' user' ,
49- password: ' pass'
51+ username: " user" ,
52+ password: " pass"
5053 }
5154 } as AxiosProxyConfig
5255 }
@@ -55,9 +58,9 @@ const agent = new BrowserAgent({
5558// Example Lambda handler
5659export const handler = async (event ) => {
5760 const page = await agent .newPage ();
58- await page .goto (' https://ycombinator.com/companies' );
61+ await page .goto (" https://ycombinator.com/companies" );
5962
60- page .ai (' Find real estate YC startups in the latest two batches' );
63+ page .ai (" Find real estate YC startups in the latest two batches" );
6164 // ...
6265};
6366```
@@ -70,19 +73,19 @@ Connect to any remote browser instance via WebSocket. Great for:
7073- Browser farms and proxy services
7174
7275``` typescript
73- import { BrowserAgent } from ' @lightfeed/browser-agent' ;
76+ import { BrowserAgent } from " @lightfeed/browser-agent" ;
7477
7578const agent = new BrowserAgent ({
76- browserProvider: ' Remote' ,
79+ browserProvider: " Remote" ,
7780 remoteConfig: {
78- browserWSEndpoint: ' ws://your-remote-browser:9222/devtools/browser/ws'
81+ browserWSEndpoint: " ws://your-remote-browser:9222/devtools/browser/ws"
7982 }
8083});
8184
8285const page = await agent .newPage ();
83- await page .goto (' https://amazon.com' );
86+ await page .goto (" https://amazon.com" );
8487
85- page .ai (' Search for organic products and go to the second page' );
88+ page .ai (" Search for organic products and go to the second page" );
8689```
8790
8891### Local Browser
@@ -93,16 +96,16 @@ Use your local Chrome browser for development and testing. Perfect for:
9396- Quick prototyping
9497
9598``` typescript
96- import { BrowserAgent } from ' @lightfeed/browser-agent' ;
99+ import { BrowserAgent } from " @lightfeed/browser-agent" ;
97100
98101const agent = new BrowserAgent ({
99- browserProvider: ' Local'
102+ browserProvider: " Local"
100103});
101104
102105const page = await agent .newPage ();
103- await page .goto (' https://news.ycombinator.com' );
106+ await page .goto (" https://news.ycombinator.com" );
104107
105- page .ai (' Navigate to show section and go to the second post' );
108+ page .ai (" Navigate to show section and go to the second post" );
106109```
107110
108111## Contributing
0 commit comments