主题
Google 以图搜图实时 SERP HTML
本接口使用 POST 方法,路径为:
/v3/serp/google/search_by_image/live/html
实时提交一张图片、搜索引擎及地区信息,获取 Google 以图搜图结果页的原始 HTML。默认返回最多 100 条搜索结果。
所有 POST 数据使用 UTF-8 编码的 JSON 格式,并以 JSON 数组作为请求体。每次调用只能提交 1 个任务;平台限流以认证说明中的 30/60/120 次/分钟规则为准。
计费说明
每次请求均会产生费用。参考价约 ¥0.0220 / 次。
当 depth过 100 且搜索引擎返回 100 条结果时,可能产生额外费用。如果指定的 depth 高于返回结果数量,未使用部分将自动退还至账户余额。
扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求参数
请求体是 JSON 数组,数组中最多一个任务对象。
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
image_url | string | 是 | 图片 URL。搜索结果将基于该图片生成。 |
location_name | string | 条件填 | 搜索引擎地区的完整名称。当未指定 location_code 或 location_coordinate 时填。使用此参数后,无需再传另外两个地区参数。 |
location_code | integer | 条件填 | 搜索引擎地区编码。当未指定 location_name 或 location_coordinate 时填。使用此参数后,无需再传另外两个地区参数。 |
location_coordinate | string | 条件填 | 地区 GPS 坐标,格式为 纬度,经度,半径。当未指定 location_name 或 location_code 时填。 |
language_name | string | 条件填 | 搜索引擎语言的完整名称。当未指定 language_code 时填。 |
language_code | string | 条件填 | 搜索引擎语言代码。当未指定 language_name 时填。 |
se_domain | string | 否 | 搜索引擎域名。平台通常会根据地区和语言自动选择合适的域名,也可以在此参数中指定自定义域名,例如 google.co.uk、google.com.au、google.de。 |
depth | integer | 否 | SERP 解析深度,即需要获取的结果数量。默认值为 100,最大值为 700。 |
search_param | string | 否 | 搜索查询附加参数。 |
tag | string | 否 | 用户自定义任务标识,用于请求和响应结果,最大长度为 255 个字符。该值会原样出现在响应的 data 数组中。 |
地区参数说明
location_name、location_code 和 location_coordinate 三只能选择一个。
location_name示例:London,England,United Kingdomlocation_code示例:2840location_coordinate示例:53.476225,-2.243572,200
location_coordinate 的限制如下:
- 格式:
latitude,longitude,radius - 纬度和经度最多保留 7 位小数
radius最小值:199.9毫米radius最大值:199999毫米
可通过地区查询接口获取可用地区及编码:
/v3/serp/wp/locations
语言参数说明
language_name 与 language_code 二选一。
language_name示例:Englishlanguage_code示例:en
可通过语言查询接口获取可用语言及代码:
/v3/serp/wp/languages
请求示例
cURL
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/serp/google/search_by_image/live/html" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"language_code": "en",
"location_code": 2840,
"image_url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/Elon_Musk_Royal_Society.jpg"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/serp/google/search_by_image/live/html"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
payload = [
{
"language_code": "en",
"location_code": 2840,
"image_url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/Elon_Musk_Royal_Society.jpg",
}
]
response = requests.post(url, headers=headers, json=payload, timeout=60)
response.raise_for_status()
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
"请求失败,错误码:%s,错误信息:%s"
% (result.get("status_code"), result.get("status_message"))
)TypeScript
typescript
const response = await fetch(
"https://api.seermartech.cn/v3/serp/google/search_by_image/live/html",
{
method: "POST",
headers: {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify([
{
language_code: "en",
location_code: 2840,
image_url:
"https://upload.wikimedia.org/wikipedia/commons/e/ed/Elon_Musk_Royal_Society.jpg",
},
]),
}
);
const result = await response.json();
if (result.status_code === 20000) {
console.log(result);
} else {
console.error(
`请求失败,错误码:${result.status_code},错误信息:${result.status_message}`
);
}响应结构
接口返回 JSON 数据,顶层 tasks 数组。
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 局状态码。 |
status_message | string | 局提示信息。 |
time | string | 请求执行时间,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务总数。 |
tasks_error | integer | tasks 数组中执行失败的任务数。 |
tasks | array | 任务结果数组。 |
tasks 字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式。 |
status_code | integer | 任务状态码,通常位于 10000 至 60000 范围。 |
status_message | string | 任务状态说明。 |
time | string | 任务执行时间,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
result_count | integer | result 数组中的数量。 |
path | array | 请求 URL 路径。 |
data | array | 创建任务时提交的参数。 |
result | array | SERP 结果数组。 |
result 字段
| 字段 | 类型 | 说明 |
|---|---|---|
image_url | string | 请求中提交的图片 URL。 |
keyword | string | Google 根据图片出的。 |
type | string | 搜索引擎类型。 |
se_domain | string | 实使用的搜索引擎域名。 |
location_code | integer | 实使用的地区编码。 |
language_code | string | 实使用的语言代码。 |
datetime | string | 获取结果的日期和时间,格式为 YYYY-MM-DD HH:MM:SS +UTC偏移,例如 2019-11-15 12:57:46 +00:00。 |
items_count | integer | items 数组中返回的结果数量。 |
items | array | SERP 结果项数组。 |
items 字段
| 字段 | 类型 | 说明 |
|---|---|---|
page | integer | 返回的 HTML 页面序号。 |
date | string | HTML 页面抓取时间,格式为 YYYY-MM-DD HH:MM:SS +UTC偏移,例如 2019-11-15 12:57:46 +00:00。 |
html | string | 搜索结果页的原始 HTML。 |
响应示例
json
{
"version": "0.1.20200923",
"status_code": 20000,
"status_message": "Ok.",
"time": "33.3515 sec.",
"cost": 0.003,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"status_code": 20000,
"status_message": "Ok.",
"time": "33.3515 sec.",
"cost": 0.003,
"result_count": 1,
"path": [
"v3",
"serp",
"google",
"search_by_image",
"live",
"html"
],
"data": [
{
"api": "serp",
"function": "live",
"se": "google",
"se_type": "search_by_image",
"image_url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/Elon_Musk_Royal_Society.jpg",
"language_code": "en",
"location_code": 2840,
"device": "desktop",
"os": "windows"
}
],
"result": [
{
"image_url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/Elon_Musk_Royal_Society.jpg",
"keyword": "example keyword",
"type": "search_by_image",
"se_domain": "google.com",
"location_code": 2840,
"language_code": "en",
"datetime": "2019-11-15 12:57:46 +00:00",
"items_count": 1,
"items": [
{
"page": 1,
"date": "2019-11-15 12:57:46 +00:00",
"html": "<html>...</html>"
}
]
}
]
}
]
}状态码与错误处理
请根据以下字段判断请求是否成功:
- 顶层
status_code - 任务级
tasks[].status_code - 对应的
status_message
当状态码为 20000 时,表示请求成功。状态码表示请求或任务执行异常,错误信息以 status_message 为准。
实用场景
- 识别图片:批量获取搜索引擎根据图片生成的,为图片 SEO、标注和扩展提供数据依据。
- 监测图片搜索:抓取指定地区和语言下的以图搜图结果 HTML,分析品牌图片、产品图片在搜索结果中的可见性。
- 发现图片盗用页面:对原创图片执行反向图片搜索,定位可能使用该图片的网页,版权保护和维权。
- 分析竞品视觉素材覆盖:提交竞品产品图或宣传图,比较在不同市场的搜索结果,支持竞品研究和市场分析。
- 构建图片 SEO 评估流程:结合
location_code、language_code和depth参数,定期采集多地区结果,评估图片优化策略在不同市场的表现。