Files
ai-agent-book/chapter9/browser-use-rpa/browser-use/docs/cloud/v1/search.mdx
T
liqiang b119135836
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
2026-08-20 13:12:50 +00:00

115 lines
3.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Search API"
description: "Get started with Browser Use's search endpoints to extract content from websites"
icon: "magnifying-glass"
mode: "wide"
---
<Warning>
**🧪 BETA - This API is in beta - it may change and might not be available at
all times.**
</Warning>
## Why Browser Use Over Traditional Search?
**Browser Use actually browses websites like a human** while other tools return cached data from landing pages. Browser Use navigates deep into sites in real-time:
- 🔍 **Deep navigation**: Clicks through menus, forms, and multiple pages to find buried content
- 🚀 **Always current**: Live prices, breaking news, real-time analytics - not cached results
- 🎯 **No stale data**: See exactly what's on the page right now
- 🌐 **Dynamic content**: Handles JavaScript, forms, and interactive elements
- 🏠 **No surface limitations**: Gets data from pages that require navigation or interaction
**Other tools see yesterday's front door. Browser Use explores today's whole house.**
## Quick Start
The Search API allows you to quickly extract relevant content from websites using AI. There are two main endpoints:
💡 **Complete working examples** are available in the [examples/search](https://github.com/browser-use/browser-use/tree/main/examples/search) folder.
### Simple Search
Search Google and extract content from multiple top results:
```python
import aiohttp
import asyncio
async def simple_search():
payload = {
"query": "latest AI news",
"max_websites": 5,
"depth": 2
}
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
async with aiohttp.ClientSession() as session:
async with session.post(
"https://api.browser-use.com/api/v1/simple-search",
json=payload,
headers=headers
) as response:
result = await response.json()
return result
asyncio.run(simple_search())
```
### Search URL
Extract content from a specific URL:
```python
async def search_url():
payload = {
"url": "https://browser-use.com/#pricing",
"query": "Find pricing information for Browser Use",
"depth": 2
}
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
async with aiohttp.ClientSession() as session:
async with session.post(
"https://api.browser-use.com/api/v1/search-url",
json=payload,
headers=headers
) as response:
result = await response.json()
return result
asyncio.run(search_url())
```
## Parameters
- **query**: Search query or content to extract
- **depth**: How deep to navigate within each website (2-5, default: 2)
- `depth=2`: Checks main page + 1 click deeper
- `depth=3`: Checks main page + 2 clicks deeper
- `depth=5`: Thoroughly explores multiple navigation levels
- **max_websites**: Number of websites to process (simple-search only, default: 5)
- **url**: Target URL to extract from (search-url only)
## Pricing
### Simple Search
**Cost per request**: `1 cent × depth × max_websites`
Example: depth=2, max_websites=3 = 6 cents per request
### Search URL
**Cost per request**: `1 cent × depth`
Example: depth=2 = 2 cents per request