Web Search API
Search the web using multiple search engines (Google, DuckDuckGo, Bing, Baidu) with advanced filtering, geographic targeting, and pagination support.
POST
/v1/web-search/*Google 搜索
POST
/v1/web-search/google通过 Google 搜索网页,支持高级搜索运算符、地理定位、语言过滤和分页。
参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
q | string | 必填 | 搜索关键词 |
location | string | 可选 | 地理位置,用于本地化结果 |
language | string | 可选 | 结果语言过滤 |
page | integer | 可选 (默认: 0) | 分页页码 |
num | integer | 可选 (默认: 10) | 每页结果数量 |
DuckDuckGo 搜索
POST
/v1/web-search/duckduckgo通过 DuckDuckGo 搜索网页,支持区域过滤、日期过滤和分页。
参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
q | string | 必填 | 搜索关键词 |
region | string | 可选 | 区域过滤 |
page | integer | 可选 (默认: 0) | 分页页码 |
Bing 搜索
POST
/v1/web-search/bing通过 Bing 搜索网页,支持市场定位、地理过滤、安全搜索和分页。
参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
q | string | 必填 | 搜索关键词 |
market | string | 可选 | 市场/区域定位 |
cc | string | 可选 | 国家代码过滤 |
page | integer | 可选 (默认: 0) | 分页页码 |
百度搜索
POST
/v1/web-search/baidu通过百度搜索网页,支持中文语言、分页和高级过滤。
参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
q | string | 必填 | 搜索关键词 |
page | integer | 可选 (默认: 0) | 分页页码 |
pn | integer | 可选 | 结果偏移量 |
响应字段说明
/v1/web-search/google响应格式: JSON| 字段 | 类型 | 说明 |
|---|---|---|
success | boolean | 请求是否成功。 |
message | string | 本次处理结果的摘要信息。 |
data | object | null | 上游服务返回的数据;失败时通常为 null。 |
error.code | string | 失败时的机器可读错误码。 |
error.details | string | 失败原因详情。 |
data.search_information | object | 查询、结果总数、耗时和结果页 URL。 |
data.organic_results[] | object[] | 自然结果;包含 title、link、displayed_link、snippet、rank 等。 |
data.people_also_ask[] | object[] | “其他人还问”问题及答案来源。 |
data.relatedSearches[] | object[] | 相关搜索词及链接。 |
data.pagination | object | 下一页等分页信息。 |
/v1/web-search/duckduckgo响应格式: JSON| 字段 | 类型 | 说明 |
|---|---|---|
success | boolean | 请求是否成功。 |
message | string | 本次处理结果的摘要信息。 |
data | object | null | 上游服务返回的数据;失败时通常为 null。 |
error.code | string | 失败时的机器可读错误码。 |
error.details | string | 失败原因详情。 |
data.organic_results[] | object[] | 自然结果;包含 title、link、snippet、rank。 |
data.related_searches[] | object[] | 相关搜索建议(上游提供时)。 |
/v1/web-search/bing响应格式: JSON| 字段 | 类型 | 说明 |
|---|---|---|
success | boolean | 请求是否成功。 |
message | string | 本次处理结果的摘要信息。 |
data | object | null | 上游服务返回的数据;失败时通常为 null。 |
error.code | string | 失败时的机器可读错误码。 |
error.details | string | 失败原因详情。 |
data.bing_data[] | object[] | Bing 结果;包含 title、link、snippet、displayed_link、rank。 |
data.related_searches[] | object[] | 相关搜索建议(上游提供时)。 |
/v1/web-search/baidu响应格式: JSON| 字段 | 类型 | 说明 |
|---|---|---|
success | boolean | 请求是否成功。 |
message | string | 本次处理结果的摘要信息。 |
data | object | null | 上游服务返回的数据;失败时通常为 null。 |
error.code | string | 失败时的机器可读错误码。 |
error.details | string | 失败原因详情。 |
data.Baidu_data[] | object[] | 百度结果;包含 title、link、snippet、rank。注意字段 B 为大写。 |
data.related_searches[] | object[] | 相关搜索建议(上游提供时)。 |
响应
Response
{
"success": true,
"message": "Google web search completed successfully",
"data": {
"search_information": {
"total_results": 1250000
},
"organic_results": [
{
"title": "Large Language Models: A Survey",
"link": "https://example.com/llm-survey",
"snippet": "A comprehensive survey of large language models...",
"position": 1
}
],
"people_also_ask": [],
"relatedSearches": []
}
}示例
import requests
API_KEY = "your_api_key_here"
BASE_URL = "https://api.qinyanai.com"
# Google web search
response = requests.post(
f"{BASE_URL}/v1/web-search/google",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"q": "large language models survey", "num": 10}
)
# DuckDuckGo search
response = requests.post(
f"{BASE_URL}/v1/web-search/duckduckgo",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"q": "machine learning tutorial", "region": "us-en"}
)
# Bing search
response = requests.post(
f"{BASE_URL}/v1/web-search/bing",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"q": "deep learning", "market": "en-US"}
)
# Baidu search (Chinese)
response = requests.post(
f"{BASE_URL}/v1/web-search/baidu",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"q": "人工智能最新进展"}
)