A minimalist, self-contained Python agent that uses LLMs to autonomously browse the web and achieve user-defined goals.
- Goal-Driven: Accepts natural language goals (e.g., "find shoes under 2000 pkr")
- Smart Perception: Extracts visible and interactive HTML elements
- LLM Decision Making: Uses structured prompts for intelligent action planning
- Browser Automation: Executes actions via Playwright/Patchright (click, type, scroll)
The agent operates in a continuous Observe → Decide → Act loop:
- 👁️ Observe: Extracts visible elements (inputs, buttons, links) and their attributes
- 🧠 Decide: Sends page state + goal to LLM, receives JSON action plan
- ✋ Act: Executes the action in browser using Playwright/Patchright
This loop continues until the LLM determines the goal is achieved.
- Python 3.9+
- Configured Gemini API environment
# Install dependencies
pip install patchrightpython browser_agent.pyEnter your goal when prompted, or press Enter to use the default goal. A Chrome window will launch and execute actions autonomously.
# Example goal
"Find running shoes under 2000 PKR on an e-commerce site"The agent will:
- Navigate to the site
- Search for products
- Filter by price
- Report findings
User Goal → Observe Page → LLM Planning → Execute Action → Repeat
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions, issues, and feature requests are welcome!
This tool is for educational purposes. Ensure compliance with website terms of service when using automated browsing.
Made with ❤️ using Python & LLMs