AI-powered browser automation with natural language
Project description
BrowserHand
BrowserHand is an AI-powered Python library that allows you to control web browsers using natural language. Built on top of Playwright, it provides a simple and intuitive API to automate web interactions without having to write complex automation code.
Features
- 🧠 Natural Language Control: Control browsers using plain English instructions
- 🔍 Smart Data Extraction: Extract structured data from web pages with simple prompts
- 🔎 DOM Observation: Intelligently identify interactive elements on a page
- ⚡ Fast & Reliable: Built on Playwright for cross-browser support and reliability
- 🔗 Works with existing Playwright code: Integrate with your existing Playwright automation
Installation
pip install browserhand
BrowserHand requires Python 3.7+.
After installing, you'll need to install the Playwright browsers:
playwright install
Quick Start
from browserhand import BrowserHand
from langchain_openai import ChatOpenAI
# Initialize a chat model
llm = ChatOpenAI(model="gpt-4o", temperature=0, api_key="your-openai-api-key")
# Initialize BrowserHand with the model
browser = BrowserHand(llm=llm)
try:
# Navigate to a website
browser.goto("https://www.example.com")
# Use natural language to perform actions
browser.Act("Click on the 'Learn more' button and then scroll down")
# Extract data using natural language
data = browser.Extract(
"Find the main heading and the first paragraph of text",
{"heading": "string", "paragraph": "string"}
)
print(data)
# Get interactive elements
elements = browser.Observe()
print(f"Found {len(elements)} interactive elements")
finally:
browser.close()
API Reference
BrowserHand Class
The main class for browser automation with natural language.
browser = BrowserHand(
llm=None, # Any LangChain chat model (required)
headless=False # Run browser in headless mode
)
Core Methods
- goto(url: str) -> None: Navigate to the specified URL.
- Act(prompt: str) -> Dict[str, Any]: Perform actions described in natural language.
- Extract(instruction: str, schema: Dict[str, str]) -> Dict[str, Any]: Extract data from the page.
- Observe() -> List[Dict[str, Any]]: Get interactive elements on the page.
- close() -> None: Close the browser and clean up resources.
Supported LLM Providers
BrowserHand supports any chat model from the LangChain ecosystem, including:
- OpenAI (via
langchain_openai) - Azure OpenAI (via
langchain_openai) - Anthropic (via
langchain_anthropic)
Command Line Interface
BrowserHand includes a command line interface:
# Navigate and perform an action
browserhand --url "https://www.example.com" --action "Click on the first button"
# Extract data
browserhand --url "https://www.example.com" --extract "Get the main heading" --schema "heading:string"
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file browserhand-0.1.2.tar.gz.
File metadata
- Download URL: browserhand-0.1.2.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
260f3a476a74fe7a34374ce66a8e529fd2085093f99b640cd4b908bc66aa37fe
|
|
| MD5 |
caa8f938bf134c0e123ed278c02c57ab
|
|
| BLAKE2b-256 |
3ee4cd8890e00c7698595a94705fc2a9b553e4b182bc25569cc6c0294b1dc8be
|
File details
Details for the file browserhand-0.1.2-py3-none-any.whl.
File metadata
- Download URL: browserhand-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44cd48f03c2c7576f625181bc142ab37da36da8e65d5a4a583b8285dfb4f7482
|
|
| MD5 |
ad256628ca9ff5438edf075b5153feec
|
|
| BLAKE2b-256 |
312fc338e5343fd10bfc6e28dd99043cf0242b3b3c21029fe759caa8ddfeefb6
|