๐Ÿ’ป Code Examples

Practical examples to help you get started with Browser AI Agent. Copy, modify, and run these examples to learn automation techniques.

๐Ÿš€

Basic Usage

Simple examples to get you started with browser automation. Perfect for beginners learning the basics.

Beginner Web Search Navigation
import asyncio from browser_ai_agent import execute_browser_task async def main(): result = await execute_browser_task( "Go to Google and search for 'Python programming'", headless=False, debug=True ) print(f"Success: {result.success}") asyncio.run(main())
โšก

Advanced Workflows

Complex multi-step automation workflows with error handling, data extraction, and parallel processing.

Advanced Multi-step Data Extraction Error Handling
async def advanced_workflow(): async with BrowserAIAgent(debug=True) as agent: tasks = [ "Navigate to Amazon and search for 'wireless headphones'", "Filter results by customer rating (4+ stars)", "Extract top 5 products with prices and ratings" ] results = await agent.execute_multiple_tasks(tasks) return results
๐Ÿ›’

E-commerce Automation

Automate product research, price monitoring, and competitive analysis across multiple e-commerce platforms.

E-commerce Price Monitoring Product Research
async def monitor_prices(): products = [ "https://amazon.com/product/123", "https://ebay.com/item/456" ] async with BrowserAIAgent() as agent: for url in products: result = await agent.execute_task( f"Extract product name, price, and rating from {url}" ) print(f"Product data: {result.extracted_data}")
๐Ÿ“

Form Automation

Intelligent form filling with validation, error handling, and multi-step form workflows.

Forms Validation Multi-step
async def fill_contact_form(): form_data = { "name": "John Doe", "email": "john@example.com", "message": "Hello from Browser AI Agent!" } async with BrowserAIAgent() as agent: await agent.navigate_to("https://example.com/contact") result = await agent.execute_task( f"Fill out the contact form with: {form_data}" )
๐Ÿ“Š

Data Scraping

Intelligent web scraping with AI-powered content extraction, pagination handling, and structured data output.

Web Scraping Data Extraction Pagination
async def scrape_news_articles(): async with BrowserAIAgent() as agent: result = await agent.execute_task(""" Go to Hacker News and extract: - Article titles - URLs - Points/votes - Number of comments From the first 2 pages """) return result.extracted_data
๐Ÿงช

Testing Automation

Automated testing workflows with AI-powered validation, regression testing, and comprehensive reporting.

Testing QA Validation
async def test_website_functionality(): test_cases = [ "Verify login form accepts valid credentials", "Check that navigation menu works correctly", "Validate search functionality returns results" ] async with BrowserAIAgent() as agent: for test in test_cases: result = await agent.execute_task(test) assert result.success, f"Test failed: {test}"

Want to contribute examples?

Share your automation workflows with the community. Submit your examples via GitHub!

Contribute on GitHub API Reference Quick Start