Skip to content
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

Check your Python version:

python --version

Setup

1. Create a Virtual Environment

Windows:

python3.13 -m venv .venv
.venv\Scripts\activate

Linux / macOS:

python3.13 -m venv .venv
source .venv/bin/activate

2. Install Dependencies

pip install browser-use
pip install playwright
playwright install chromium --with-deps

Configure Environment Variables

Create a .env file and add your Google Gemini API key:

Windows:

echo. > .env

Linux / macOS:

touch .env

Inside .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.py

The agent will automatically launch a browser, perform the task, and display results.

Last updated on