Use Serpshot Google Search API to perform web searches and image searches.
使用 Serpshot API 执行 Google 网页搜索和图片搜索。
python
import requests
import os
apikey = os.environ.get(SERPSHOTAPI_KEY)
if not api_key:
raise ValueError(SERPSHOTAPIKEY 未设置。请在 https://serpshot.com/dashboard 获取密钥)
response = requests.post(
https://api.serpshot.com/api/search/google,
headers={X-API-Key: api_key, Content-Type: application/json},
json={
queries: [在此输入搜索查询],
type: search,
num: 10, # 每页结果数(1-100)
gl: us, # 国家代码:us/cn/gb/jp/de/ca/fr/...
hl: en, # 语言:en/zh-Hans/ja/...
}
)
data = response.json()
if data.get(code) != 200:
raise RuntimeError(fAPI 错误 {data.get(code)}: {data.get(msg)})
for r in data[data][results]:
print(f{r[position]}. {r[title]})
print(f {r[link]})
print(f {r[snippet]})
print()
python
import requests
import os
apikey = os.environ.get(SERPSHOTAPI_KEY)
response = requests.post(
https://api.serpshot.com/api/search/google,
headers={X-API-Key: api_key, Content-Type: application/json},
json={
queries: [在此输入图片查询],
type: image,
num: 10,
gl: us,
}
)
data = response.json()
if data.get(code) != 200:
raise RuntimeError(fAPI 错误 {data.get(code)}: {data.get(msg)})
for r in data[data][results]:
print(f{r[position]}. {r[title]})
print(f 来源:{r.get(source, )})
print(f 链接:{r[link]})
print(f 缩略图:{r.get(thumbnail, )})
print()
| 参数 | 默认值 | 描述 |
|---|---|---|
| queries | 必填 | 搜索查询数组(最多 100 个) |
| type |
json
{
code: 200,
msg: 成功,
data: {
results: [
{
title: 结果标题,
link: https://example.com,
snippet: 结果描述...,
position: 1
}
],
total_results: 约 12,300,000 条结果,
search_time: 0.45,
credits_used: 1
}
}
queries: [AI news 2026]
gl: us
num: 5
queries: [人工智能 最新消息]
gl: cn
hl: zh-Hans
num: 10
queries: [minimalist UI design]
type: image
num: 10
| 代码 | 含义 | 操作 |
|---|---|---|
| 400 | 错误请求 | 检查参数格式 |
| 401 |
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 serpshot-1776155221 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 serpshot-1776155221 技能
skillhub install serpshot-1776155221
文件大小: 2.32 KB | 发布时间: 2026-4-15 13:06