这是一个强大的搜索API服务,支持从多个搜索引擎获取信息。它是从OnlineGPT桌面应用改造而来的Web API服务,专门设计用于与GPT等大型语言模型集成。
- 支持多个搜索引擎 (Google、Bing、百度)
- 自动提取网页内容
- RESTful API接口
- 支持自定义搜索数量
- 支持批量关键词搜索
- 异步处理请求
- 自动编码检测和处理
POST /search
请求体:
{
"queries": ["搜索关键词1", "搜索关键词2"],
"num_results": 5,
"engine": "Google",
"custom_question": "可选的自定义问题"
}参数说明:
queries: 搜索关键词列表num_results: 每个关键词返回的结果数量 (默认5)engine: 搜索引擎选择 ("Google", "Bing", "百度")custom_question: 可选的自定义问题
响应示例:
{
"status": "success",
"query": ["搜索关键词1", "搜索关键词2"],
"engine": "Google",
"custom_question": "自定义问题",
"results": [
{
"title": "页面标题",
"link": "页面URL",
"snippet": "搜索结果摘要",
"content": "页面内容"
}
]
}- Fork本仓库
- 在Vercel中导入项目
- 部署完成后即可使用
- 克隆仓库:
git clone https://github.com/yourusername/onlinegpt-api.git
cd onlinegpt-api- 安装依赖:
pip install -r requirements.txt- 运行服务:
uvicorn main:app --reload- 访问API文档:
http://localhost:8000/docs
import requests
api_url = "https://your-api-url.vercel.app/search"
data = {
"queries": ["Python programming", "AI development"],
"num_results": 5,
"engine": "Google"
}
response = requests.post(api_url, json=data)
results = response.json()curl -X POST "https://your-api-url.vercel.app/search" \
-H "Content-Type: application/json" \
-d '{"queries":["Python programming"],"num_results":5,"engine":"Google"}'- 请遵守搜索引擎的使用条款
- 建议添加适当的请求限制
- 在生产环境中请设置适当的CORS策略
- 建议添加缓存机制以提高性能
- 注意处理并发请求
本项目采用 MIT 许可证。详见 LICENSE 文件。