browser-use
browser-use
Web Scraping with browser-use and Google AI Gemini Flash 2.5
This guide shows how to use browser-use with Google AI Gemini Flash 2.5 to automate browsing and perform structured web scraping. The Gemini Flash 2.5 model includes 1,000 free requests, making it a great option for small scraping or automation projects.
Prerequisites
- Python 3.13+
- A Google AI Studio API key: Get one here
Check your Python version:
python --versionSetup
1. Create a Virtual Environment
Windows:
python3.13 -m venv .venv
.venv\Scripts\activateLinux / macOS:
python3.13 -m venv .venv
source .venv/bin/activate2. Install Dependencies
pip install browser-use
pip install playwright
playwright install chromium --with-depsConfigure Environment Variables
Create a .env file and add your Google Gemini API key:
Windows:
echo. > .envLinux / macOS:
touch .envInside .env:
GEMINI_API_KEY=your_api_key_here
Example Script
Save the following as agent.py:
from browser_use import Agent, ChatGoogle
from dotenv import load_dotenv
import asyncio
load_dotenv()
async def main():
llm = ChatGoogle(
model="gemini-2.5-flash"
)
task = "Find the number 1 post on Show HN"
agent = Agent(task=task, llm=llm)
await agent.run()
if __name__ == "__main__":
asyncio.run(main())Run the script:
python agent.pyThe agent will automatically launch a browser, perform the task, and display results.
Last updated on