Brightdata Tools

Scrape a webpage as Markdown with BrightDataTools, using include and exclude tool filters.

brightdata_tools.py
"""
Brightdata Tools
=============================

Demonstrates brightdata tools.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.brightdata import BrightDataTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


# Example 1: Include specific BrightData functions for web scraping
scraping_agent = Agent(
    model=OpenAIChat(id="gpt-5.6-luna"),
    tools=[
        BrightDataTools(include_tools=["web_scraper", "serp_google", "serp_amazon"])
    ],
    markdown=True,
)

# Example 2: Exclude screenshot functions for performance
no_screenshot_agent = Agent(
    model=OpenAIChat(id="gpt-5.6-luna"),
    tools=[BrightDataTools(exclude_tools=["screenshot_generator"])],
    markdown=True,
)

# Example 3: Full BrightData functionality (default)
agent = Agent(
    model=OpenAIChat(id="gpt-5.6-luna"),
    tools=[BrightDataTools()],
    markdown=True,
)

# Example 1: Scrape a webpage as Markdown

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response(
        "Scrape this webpage as markdown: https://docs.agno.com/introduction",
    )

    # Example 2: Take a screenshot of a webpage
    # agent.print_response(
    #     "Take a screenshot of this webpage: https://docs.agno.com/introduction",
    # )

    # response = agent.run_response
    # if response.images:
    #     save_base64_data(response.images[0].content, "tmp/agno_screenshot.png")

    # Add a new SERP API zone: https://brightdata.com/cp/zones/new
    # Example 3: Search using Google
    # agent.print_response(
    #     "Search Google for 'Python web scraping best practices' and give me the top 5 results",
    # )

    # Example 4: Get structured data from Amazon product
    # agent.print_response(
    #     "Get detailed product information from this Amazon product: https://www.amazon.com/dp/B0D2Q9397Y?th=1&psc=1",
    # )

    # Example 5: Get LinkedIn profile data
    # agent.print_response(
    #     "Search for Satya Nadella on LinkedIn and give me a summary of his profile"
    # )

Current tool names and zones

For Example 1, replace the include list with include_tools=["scrape_as_markdown", "search_engine"]. Both Google and Amazon searches use search_engine; web_scraper, serp_google, and serp_amazon are not registered names. For Example 2, use exclude_tools=["get_screenshot"].

Create a Web Unlocker zone in your account and set BRIGHT_DATA_WEB_UNLOCKER_ZONE to its name. Search examples additionally require BRIGHT_DATA_SERP_ZONE for an active SERP zone. The defaults are web_unlocker1 and serp_api.

The commented screenshot recipe is not ready to run: it refers to agent.run_response and an unimported helper, and the toolkit currently double-encodes screenshot bytes. Use the Markdown scraping example here; see Bright Data for the supported surface and limitations.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai requests

Export your API keys

export BRIGHT_DATA_API_KEY="your_bright_data_api_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"

Run the example

Save the code above as brightdata_tools.py, then run:

python brightdata_tools.py

Full source: cookbook/91_tools/brightdata_tools.py