A small, professional Python CLI that demonstrates agent-based browser automation using browser-use. The tool opens a URL with a browser agent, extracts simple but useful page information, and saves the result as JSON.
This repository is intentionally minimal and structured to reflect a realistic interview-level use case for Browser-Use–based agent workflows.
Given a URL, the CLI tool:
- Uses a browser-use Agent to open and navigate to the page
- Waits until the page is fully loaded
- Extracts:
- Page title
- Headings (h1–h3)
- A small set of links (text + href)
- Saves the extracted data to a JSON file
This project uses uv for dependency management.
uv syncCreate a .env file in the repository root:
BROWSER_USE_API_KEY=your_api_key_hereNote: Tests do NOT require a browser or API key. The API key is only required when running the CLI scrape command.
uv run -m src.agent.cli scrape --url "https://news.ycombinator.com" --out result.jsonAfter completion, the extracted data will be saved to result.json.
{
"title": "Hacker News",
"headings": [],
"links": [
{
"text": "new",
"href": "news"
},
{
"text": "past",
"href": "front"
}
]
}browser-use-mini-agent/
├─ src/agent/
│ ├─ __init__.py
│ ├─ cli.py # CLI entrypoint
│ ├─ browser.py # Browser-Use / agent logic
│ ├─ extract.py # Pure HTML → data extraction
│ └─ models.py # Pydantic output models
├─ tests/
│ ├─ test_extract.py
│ └─ fixtures/
│ └─ sample.html
├─ examples/
│ └─ example_output.json
├─ pyproject.toml
└─ README.md
- Agent-first approach: page navigation is handled by a Browser-Use agent, not direct HTTP requests
- Separation of concerns: browser automation and HTML parsing are strictly separated
- Testability: extraction logic is pure and tested using static HTML fixtures
- Browser automation can be flaky depending on network conditions and rendering timing
- Extraction logic is intentionally generic and does not handle complex client-side frameworks
- This is a minimal demo, not a full crawler or production scraper
This repository demonstrates:
- Agent-based workflows with Browser-Use
- Clean Python project structure
- Testable extraction logic
- A realistic, interview-ready CLI use case