ScavioScavio
产品定价文档
登录开始使用
  1. 首页
  2. 教程
  3. 如何使用 Google Maps API 数据构建本地 SEO 检查器
教程

如何使用 Google Maps API 数据构建本地 SEO 检查器

使用 Python 构建本地 SEO 检查器,使用 Scavio API 分析 Google 地图列表和本地包结果。根据本地 SEO 因素对企业进行评分。

获取免费API密钥API文档

本地 SEO 决定企业是否出现在 Google 地图和地理定位查询的本地包中。本地 SEO 检查器会分析企业在本地结果中的显示情况:其评级、评论数量、是否拥有网站以及相对于竞争对手的排名如何。本教程使用 Scavio API 构建本地 SEO 检查器,查询目标关键字的本地结果,评估企业列表质量,并生成本地 SEO 得分报告。

前置条件

  • Python 3.8 或更高版本
  • 请求已安装库
  • Scavio API 密钥
  • 要检查的公司名称和地点

操作指南

步骤 1: 获取目标关键词的本地结果

搜索您的企业应排名的本地意图关键字。 local_results 字段包含 Google 地图列表。

Python
def get_local_results(keyword: str, location: str) -> list[dict]:
    r = requests.post(
        "https://api.scavio.dev/api/v1/search",
        headers={"x-api-key": API_KEY},
        json={"query": f"{keyword} in {location}", "country_code": "us"}
    )
    r.raise_for_status()
    return r.json().get("local_results", [])

步骤 2: 在结果中找到目标企业

扫描本地结果以查找目标企业名称。如果找到,则返回其位置和列表详细信息。

Python
def find_business(results: list[dict], business_name: str) -> dict | None:
    for i, r in enumerate(results):
        if business_name.lower() in r.get("title", "").lower():
            return {"position": i + 1, **r}
    return None

步骤 3: 对列表质量进行评分

根据评级、评论计数、网站存在和电话号码可用性计算本地 SEO 分数。

Python
def score_listing(listing: dict) -> dict:
    score = 0
    factors = {}
    rating = float(listing.get("rating", 0) or 0)
    if rating >= 4.5:
        score += 30
        factors["rating"] = f"{rating}/5 (excellent)"
    elif rating >= 4.0:
        score += 20
        factors["rating"] = f"{rating}/5 (good)"
    else:
        factors["rating"] = f"{rating}/5 (needs improvement)"
    reviews = int(listing.get("reviews", 0) or 0)
    if reviews >= 100:
        score += 25
    elif reviews >= 20:
        score += 15
    factors["reviews"] = str(reviews)
    if listing.get("website"):
        score += 20
        factors["website"] = "present"
    else:
        factors["website"] = "missing"
    if listing.get("phone"):
        score += 15
        factors["phone"] = "present"
    else:
        factors["phone"] = "missing"
    return {"score": score, "max_score": 90, "factors": factors}

步骤 4: 生成本地 SEO 报告

对多个关键字运行检查器并输出全面的本地 SEO 报告。

Python
def local_seo_check(business: str, location: str, keywords: list[str]) -> None:
    print(f"Local SEO Report: {business} in {location}\n" + "=" * 50)
    for kw in keywords:
        results = get_local_results(kw, location)
        match = find_business(results, business)
        if match:
            scores = score_listing(match)
            print(f"\n{kw}: Position #{match['position']}, Score: {scores['score']}/{scores['max_score']}")
        else:
            print(f"\n{kw}: Not found in local results")

Python 示例

Python
import os
import requests

API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")
ENDPOINT = "https://api.scavio.dev/api/v1/search"

def get_local(kw: str, loc: str) -> list[dict]:
    r = requests.post(ENDPOINT, headers={"x-api-key": API_KEY},
                      json={"query": f"{kw} in {loc}", "country_code": "us"})
    r.raise_for_status()
    return r.json().get("local_results", [])

def score(listing: dict) -> int:
    s = 0
    if float(listing.get("rating") or 0) >= 4.0: s += 25
    if int(listing.get("reviews") or 0) >= 50: s += 25
    if listing.get("website"): s += 25
    if listing.get("phone"): s += 15
    return s

if __name__ == "__main__":
    business = "Joe's Coffee"
    keywords = ["coffee shop", "best coffee", "cafe near me"]
    for kw in keywords:
        results = get_local(kw, "Austin, TX")
        match = next((r for r in results if business.lower() in r.get("title", "").lower()), None)
        if match:
            print(f"{kw}: #{results.index(match)+1}, score={score(match)}/90")
        else:
            print(f"{kw}: not found")

JavaScript 示例

JavaScript
const API_KEY = process.env.SCAVIO_API_KEY || "your_scavio_api_key";
const ENDPOINT = "https://api.scavio.dev/api/v1/search";

async function getLocal(kw, loc) {
  const res = await fetch(ENDPOINT, {
    method: "POST",
    headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
    body: JSON.stringify({ query: `${kw} in ${loc}`, country_code: "us" })
  });
  const data = await res.json();
  return data.local_results || [];
}

async function main() {
  const business = "Joe's Coffee";
  const keywords = ["coffee shop", "best coffee"];
  for (const kw of keywords) {
    const results = await getLocal(kw, "Austin, TX");
    const idx = results.findIndex(r => r.title?.toLowerCase().includes(business.toLowerCase()));
    if (idx >= 0) {
      console.log(`${kw}: #${idx + 1}, rating: ${results[idx].rating}`);
    } else {
      console.log(`${kw}: not found`);
    }
  }
}
main().catch(console.error);

预期输出

JSON
Local SEO Report: Joe's Coffee in Austin, TX
==================================================

coffee shop: Position #3, Score: 75/90
  rating: 4.7/5 (excellent)
  reviews: 234
  website: present
  phone: present

best coffee: Position #5, Score: 65/90

cafe near me: Not found in local results

相关教程

  • 如何在不被阻止的情况下抓取谷歌地图业务数据
  • 如何使用 SERP 和竞争对手分析构建 SEO 审核工具

常见问题

大多数开发者在15到30分钟内完成本教程。您需要一个Scavio API密钥(免费套餐即可)和可用的Python或JavaScript环境。

Python 3.8 或更高版本. 请求已安装库. Scavio API 密钥. 要检查的公司名称和地点. Scavio API密钥注册即送50个免费积分。

可以。免费套餐注册即送50个积分,完全足够完成本教程并构建一个可运行的原型解决方案。

Scavio提供原生LangChain包(langchain-scavio)、MCP服务器以及适用于任何HTTP客户端的REST API。本教程使用 the raw REST API, 但您可以根据需要适配您选择的框架。

相关资源

Best Of

2026年最佳代理机构 SEO 报告 API

Read more
Best Of

AppSumo SEO 工具的最佳 API 替代品 (2026)

Read more
Solution

构建可预测成本的SEO API层

Read more
Glossary

搜索 API 供应商格局(2026)

Read more
Use Case

SEO 仪表板原始 API

Read more
Use Case

AppSumo SEO 工具到 API 迁移

Read more

开始构建

使用 Python 构建本地 SEO 检查器,使用 Scavio API 分析 Google 地图列表和本地包结果。根据本地 SEO 因素对企业进行评分。

获取免费API密钥阅读文档
ScavioScavio

面向AI智能体的实时搜索API。搜索所有平台,不仅仅是Google。

产品

  • 功能
  • 定价
  • 控制台
  • 联盟计划

开发者

  • 文档
  • API参考
  • 快速开始
  • MCP集成
  • Python SDK

替代方案

  • Tavily替代方案
  • SerpAPI替代方案
  • Firecrawl替代方案
  • Exa替代方案

工具

  • JSON格式化
  • cURL转代码
  • Token计数器
  • 全部工具

© 2026 Scavio. 保留所有权利。

Featured on TAAFT
服务条款隐私政策