AI agent instructions
AI agent instructions
Prerequisites
Install Puppeteer and the Notte SDK in your Node.js project:Use
puppeteer-core instead of puppeteer since you’re connecting to a remote browser rather than launching a local one.Approach 1: Start Session with the Node.js SDK
Start a Notte session with the Node.js SDK, get its CDP URL withsession.cdpUrl(), and connect Puppeteer. session.use() stops the session when the callback finishes:
Approach 2: Start Session from Python
Start a Notte session in Python and pass its CDP URL to a Node.js Puppeteer script:Network Interception
Use Puppeteer’s request interception with Notte sessions:Page Manipulation
Use Puppeteer’s API for advanced page interactions:Multiple Pages
Create and manage multiple pages with Puppeteer:Event Monitoring
Listen to browser events using Puppeteer:Screenshots and PDFs
Generate screenshots and PDFs using Puppeteer:Best Practices
1. Use puppeteer-core
Always usepuppeteer-core instead of puppeteer since you’re connecting to a remote browser:
2. Handle Disconnections
CDP connections can be interrupted. Always wrap operations in try-catch:3. Disconnect Properly
Always disconnect the browser when done:4. Session Timeout
Remember that Notte sessions have a timeout. Set an appropriate value when creating the session:puppeteer_session_timeout.py
5. Environment Variables
Store your Notte API key in environment variables:Complete Example: Web Scraping
Here’s a complete example that drives the REST API directly, without an SDK. Sessions are started withPOST /sessions/start and stopped with DELETE /sessions/{session_id}/stop:
When to Use Puppeteer with Notte
Use Puppeteer directly when you need:- Node.js ecosystem: Integrate with Node.js applications and packages
- Familiar Puppeteer API: You’re already comfortable with Puppeteer’s API
- Request interception: Block resources or modify requests
- Performance monitoring: Track page metrics and performance
- PDF generation: Create PDFs from web pages
Next Steps
Connect with Playwright
Use Playwright with Notte sessions
Migrating from Selenium
Port Selenium scripts to Playwright
External Browser Providers
Connect Notte to Kernel.sh and other providers
API Reference
Explore the Notte REST API