Documentation Index
Fetch the complete documentation index at: https://docs.brightdata.com/llms.txt
Use this file to discover all available pages before exploring further.
迁移优势
- 最小代码更改即可替换
- 1:1 兼容 JSON 响应结构
- 增强的请求灵活性,支持基于查询和基于 URL 的请求
快速开始迁移(5 分钟)
更新端点
将 api.bing.microsoft.com 替换为 api.brightdata.com/request
在请求体中添加参数并测试首个请求
curl -X POST 'https://api.brightdata.com/request' \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"search_engine": "bing",
"query": "test search",
"data_format": "parsed_bing_api",
"format": "json",
"zone": "your_zone_name_"
}'
逐步迁移指南
步骤 1:账户设置
用 Bright Data 凭据替换你的 Bing API key:之前(Bing):Ocp-Apim-Subscription-Key: YOUR_BING_KEY
之后(Bright Data):Authorization: Bearer YOUR_BRIGHTDATA_API_KEY
步骤 2:更新请求格式
之前(Bing API):curl -X GET "https://api.bing.microsoft.com/v7.0/search?q=openai" \
-H "Ocp-Apim-Subscription-Key: YOUR_BING_KEY"
之后(Bright Data):curl -X POST "https://api.brightdata.com/request" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"search_engine": "bing",
"query": "openai",
"data_format": "parsed_bing_api",
"format": "json",
"zone": "your_zone_name"
}'
之前(Bing API):import requests
headers = {
'Ocp-Apim-Subscription-Key': 'YOUR_BING_KEY'
}
response = requests.get(
'https://api.bing.microsoft.com/v7.0/search',
headers=headers,
params={'q': 'openai'}
)
之后(Bright Data):import requests
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
payload = {
'search_engine': 'bing',
'query': 'openai',
'data_format': 'parsed_bing_api',
'format': 'json',
'zone': 'your_zone_name'
}
response = requests.post(
'https://api.brightdata.com/request',
headers=headers,
json=payload
)
之前(Bing API):const axios = require('axios');
const response = await axios.get(
'https://api.bing.microsoft.com/v7.0/search',
{
headers: {
'Ocp-Apim-Subscription-Key': 'YOUR_BING_KEY'
},
params: { q: 'openai' }
}
);
之后(Bright Data):const axios = require('axios');
const response = await axios.post(
'https://api.brightdata.com/request',
{
search_engine: 'bing',
query: 'openai',
data_format: 'parsed_bing_api',
format: 'json',
zone: 'your_zone_name'
},
{
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
}
);
步骤 3:处理响应格式
使用 data_format: "parsed_bing_api" 时,响应格式与 Bing API 保持一致:
{
"_type": "SearchResponse",
"queryContext": {
"originalQuery": "openai"
},
"webPages": {
"totalEstimatedMatches": 12300000,
"value": [
{
"name": "OpenAI",
"url": "https://openai.com/",
"displayUrl": "openai.com",
"snippet": "OpenAI is an AI research and deployment company..."
}
]
},
"images": { "value": [...] },
"videos": { "value": [...] },
"relatedSearches": { "value": [...] }
}