如何采集 Google Local Pack 搜索结果
了解如何使用 SERP API 采集 Google Local Pack 结果,提取商家名称、排名、评分、评论数、地址、网站、电话和本地 SEO metadata。
Google Local Pack 是当用户搜索带有本地意图的 query 时,Google 搜索结果中出现的本地商家列表,例如 “dentist near me”、“coffee shop in Austin” 或 “best plumber in Chicago”。
对 Local SEO 团队来说,Local Pack 往往比普通 organic links 更重要。它能显示某个城市、街区或服务范围内,哪些商家真正出现在用户面前。
要采集 Google Local Pack results,较稳定的方式是使用 SERP API:发送本地化 search query,获取结构化 JSON,然后提取 business name、ranking position、rating、review count、address、phone number、website 和 place ID 等字段。
可以采集哪些数据?
Google Local Pack result 通常是商家级数据,而不是普通网页结果。
|
字段 |
为什么重要 |
|
|
本地排名位置 |
|
|
商家名称 |
|
|
平均评分 |
|
|
评论数 |
|
|
商家地址 |
|
|
联系电话 |
|
|
商家网站 |
|
|
稳定商家识别码 |
|
|
经纬度 |
|
|
商家分类 |
|
|
营业时间,如果有 |
基础 Local Pack Request
一个通用 request 可能像这样:
{
"engine": "google_local",
"query": "coffee shops in Seattle",
"location": "Seattle, Washington, United States",
"language": "en",
"device": "desktop",
"output": "json"
}
不同供应商可能使用 google_maps、google_local,或在标准 google engine 中返回 local results。参数命名可能不同,但核心概念一致:定义 query、location、language 和 output format。
对 Local SEO 来说,location 不是可有可无的参数。同一个 “emergency dentist”,在 New York、Dallas、Miami 和 San Jose 可能返回完全不同的商家。
Python 示例:抓取并解析 Local Pack Results
下面是 provider-neutral 示例。你可以根据所选 SERP API 调整 endpoint 和 authentication。
import os
import csv
import requests
SERP_API_KEY = os.getenv("SERP_API_KEY")
SERP_API_ENDPOINT = os.getenv("SERP_API_ENDPOINT")
def clean_text(value):
if not value:
return ""
return " ".join(str(value).split())
def fetch_local_pack(query, location):
params = {
"engine": "google_local",
"query": query,
"location": location,
"language": "en",
"device": "desktop",
"output": "json"
}
headers = {
"Authorization": f"Bearer {SERP_API_KEY}"
}
response = requests.get(
SERP_API_ENDPOINT,
params=params,
headers=headers,
timeout=30
)
response.raise_for_status()
return response.json()
def extract_local_results(serp_json):
raw_results = (
serp_json.get("local_results")
or serp_json.get("places_results")
or serp_json.get("maps_results")
or []
)
extracted = []
for index, item in enumerate(raw_results, start=1):
coordinates = item.get("gps_coordinates") or {}
extracted.append({
"position": item.get("position") or index,
"business_name": clean_text(item.get("title") or item.get("name")),
"rating": item.get("rating"),
"reviews": item.get("reviews"),
"address": clean_text(item.get("address")),
"phone": clean_text(item.get("phone")),
"website": item.get("website") or item.get("link") or "",
"place_id": item.get("place_id") or item.get("data_id") or "",
"latitude": coordinates.get("latitude"),
"longitude": coordinates.get("longitude"),
"category": clean_text(item.get("type") or item.get("category"))
})
return extracted
这样可以把原始 Local Pack JSON 转成干净的商家列表。
导出为 CSV
def save_to_csv(results, filename="google_local_pack_results.csv"):
fieldnames = [
"position",
"business_name",
"rating",
"reviews",
"address",
"phone",
"website",
"place_id",
"latitude",
"longitude",
"category"
]
with open(filename, "w", newline="", encoding="utf-8") as file:
writer = csv.DictWriter(file, fieldnames=fieldnames)
writer.writeheader()
writer.writerows(results)
CSV 可用于 Local SEO reporting、competitor analysis、lead research 或 dashboard 导入。
加入 Search Metadata
Local Pack data 必须和搜索上下文一起保存。
def add_metadata(results, query, location, language="en", device="desktop"):
for result in results:
result["query"] = query
result["location"] = location
result["language"] = language
result["device"] = device
return results
某商家在 Seattle 的 “coffee shops” 排名第一,不代表它在 Portland 也排名第一。Query、location、language、device 和 timestamp 都应保存。
常见使用场景
Local SEO Rank Tracking
Local SEO 团队可以监测目标 keyword 在不同城市中出现的商家。
常见 query 包括:
dentist in Austin
personal injury lawyer in Miami
best coffee shop in Seattle
emergency plumber in Chicago
nearby car repair shop
Competitor Monitoring
你可以追踪哪些 competitors 出现在 Local Pack 中、排名如何变化,以及是否有新商家进入结果集。
Multi-Location Brand Monitoring
对多门店品牌来说,Local Pack data 可以帮助比较不同城市、街区和服务范围的搜索可见度。
AI Agent 和 RAG Workflow
AI Agent 可以把 Local Pack results 当作 location-based task 的 source discovery layer。例如,Agent 可以先收集本地商家,再按 rating 和 review count 筛选,最后抓取网站或评论做 deeper analysis。
如何选择 SERP API?
Local Pack scraping 应重点比较 field completeness、location control、schema stability 和 successful-request billing。
SerpApi 有 Google Local 和 Google Maps API,可提取 rating、review、address、hours、GPS coordinates 和 place ID 等本地商家字段。
Bright Data 的 SERP API 强调 JSON、HTML、Markdown output、geo-location targeting,以及 pay-only-for-successful-delivery billing。
Serper.dev 支持 Google Maps 和 Places 等 search types,并提供免费 queries 用于测试。
如果 workflow 需要 structured SERP data、geo-targeted search results、JSON / HTML output 和 multi-engine coverage,可以将 Talordata 放入测试名单。Talordata 产品页说明其 SERP API 支持 Google 和其他主要搜索引擎、geo targeting、structured output,以及 successful-request-based usage。获取1000次免费测试额度>>
实际选型方式很简单:用同一个本地 query 和同一个城市,在 2–3 个 API 中测试,然后比较 business name、position、rating、review count、address、coordinates、missing fields 和 cost per usable result。
FAQ
什么是 Google Local Pack scraping?
Google Local Pack scraping 是指从本地化 Google query 中采集 local business results 的结构化数据,包括商家名称、评分、评论数、地址、网站、电话和排名位置。
Google Local Pack 和 Google Maps 一样吗?
不完全一样。Local Pack 通常出现在 Google Search results 中,而 Google Maps 是基于地图的商家搜索体验。它们可能共享商家数据,但 layout、ranking context 和可用字段可能不同。
Local Pack results 应该提取哪些字段?
Local SEO 建议提取 position、business name、rating、review count、address、website、phone number、place ID、category、coordinates、query、location、device 和 timestamp。
可以用 Python 采集 Google Local Pack results 吗?
可以。最简单的方式是用 Python 调用 SERP API,接收 structured JSON,解析 local result array,normalize 字段,并将数据导出为 CSV 或写入数据库。
结语
采集 Google Local Pack results,本质上是从搜索结果中收集结构化本地商家数据。
先从清晰的 query 和 location 开始,再提取 workflow 需要的字段:business name、position、rating、reviews、address、website、phone、place ID 和 coordinates。
对 Local SEO 来说,它可以追踪不同城市或街区的搜索可见度。对竞品研究来说,它能显示谁出现在高意图本地 query 中。对 AI Agent 来说,它能建立结构化本地任务 source list。
最好的 workflow 很简单:发送 localized query,接收 Local Pack JSON,normalize fields,保存 metadata,并随时间比较结果变化。