Skill: phheng/google-maps-search-api (version 0.1.0)

--- name: google-maps-search-api description: This skill is designed to help users automatically extract business data from Google Maps search results. When a user asks to "find coffee shops in New York," "search for dental clinics," or "extract business leads from Google Maps," the agent should proactively apply this skill. --- # Google Maps Search Automation Skill ## ✨ Platform Compatibility **✅ Works Powerfully & Reliably On All Major AI Assistants** | Platform | Status | How to Install | |----------|--------|----------------| | **OpenCode** | ✅ Fully Supported | Copy skill folder to `~/.opencode/skills/` | | **Claude Code** | ✅ Fully Supported | Native skill support | | **Cursor** | ✅ Fully Supported | Copy to `~/.cursor/skills/` | | **OpenClaw** | ✅ Fully Supported | Compatible | **Why Choose BrowserAct Skills?** - 🚀 Stable & crash-free execution - ⚡ Fast response times - 🔧 No configuration headaches - 📦 Plug & play installation - 💬 Professional support ## 📖 Introduction This skill provides a one-stop business data collection service through the BrowserAct Google Maps Search API template. Obtain structured business data with just one command. ## 🔑 API Key Guidance Before running, check the `BROWSERACT_API_KEY` environment variable. If it is not set, do not take further action; instead, request and wait for the user to provide it. **The Agent must inform the user**: > "Since you haven't configured the BrowserAct API Key, please go to the [BrowserAct Console](https://www.browseract.com/reception/integrations) to get your Key and provide it to me in this chat." ## 🛠️ Input Parameters Details The Agent should flexibly configure the following parameters when calling the script based on user needs: 1. **KeyWords (Search Keywords)** - **Type**: `string` - **Description**: The keywords the user wants to search for on Google Maps. - **Example**: `coffee`, `bakery`, `coworking space` 2. **language (UI Language)** - **Type**: `string` - **Description**: Sets the UI language and the language of the returned text. - **Optional Values**: `en`, `de`, `fr`, `it`, `es`, `ja`, `zh-CN`, `zh-TW` - **Default**: `en` 3. **country (Country/Region Bias)** - **Type**: `string` - **Description**: Sets the country or region bias for search results. - **Example**: `us`, `gb`, `ca`, `au`, `de`, `fr`, `es`, `it`, `jp` - **Default**: `us` 4. **max_dates (Maximum extraction limit)** - **Type**: `number` - **Description**: The maximum number of places to extract from search results. - **Default**: `100` ## 🚀 Execution Method (Recommended) The Agent should implement "one command for results" by executing the following independent script: ```bash # Call example python ./scripts/google_maps_search_api.py "KeyWords" "language" "country" max_dates ``` ## 📊 Data Output Description After successful execution, the script will directly parse and print the results from the API response. Results include: - `name`: Business name - `full address`: Business address - `rating`: Average star rating - `review count`: Number of reviews - `price range`: Price level - `cuisine type`: Business category - `amenity tags`: Features like Wi-Fi, outdoor seating - `review snippet`: Highlighted short review - `service options`: Such as "Order online", "Dine-in" ## ⚠️ Error Handling & Retry During script execution, if an error occurs (such as network fluctuations or task failure), the Agent should follow this logic: 1. **Check output content**: - If the output **contains** `"Invalid authorization"`, the API Key is invalid or expired. **Do not retry**; instead, guide the user to check and provide the correct API Key. - If the output **does not contain** `"Invalid authorization"` but the task execution fails (e.g., output starts with `Error:` or returns an empty result), the Agent should **automatically attempt to re-execute** the script once. 2. **Retry Limit**: - Automatic retry is limited to **once**. If the second attempt still fails, stop retrying and report the specific error message to the user.

path: scripts/google_maps_search_api.py
content: import os
import time
import requests
import json
import sys

# API Configuration
TEMPLATE_ID = "77805072070738748"
API_BASE_URL = "https://api.browseract.com/v2/workflow"

def run_google_maps_task(api_key, keywords, language="en", country="us", max_dates=100):
    headers = {"Authorization": f"Bearer {api_key}"}
    payload = {
        "workflow_template_id": TEMPLATE_ID,
        "input_parameters": [
            {"name": "KeyWords", "value": keywords},
            {"name": "language", "value": language},
            {"name": "country", "value": country},
            {"name": "TargetURL", "value": "https://www.google.com/maps"},
            {"name": "max_dates", "value": str(max_dates)}
        ]
    }
    
    # 1. Start Task
    try:
        res = requests.post(f"{API_BASE_URL}/run-task-by-template", json=payload, headers=headers).json()
    except Exception as e:
        print(f"Error: Connection to API failed - {e}")
        return None

    if "id" not in res:
        print(f"Error: Could not start task. Response: {res}")
        return None
    
    task_id = res["id"]
    
    # 2. Poll for Completion
    while True:
        try:
            status_res = requests.get(f"{API_BASE_URL}/get-task-status?task_id={task_id}", headers=headers).json()
            status = status_res.get("status")
            
            if status == "finished":
                break
            elif status in ["failed", "canceled"]:
                print(f"Error: Task {status}. Please check your BrowserAct dashboard.")
                return None
        except Exception as e:
            # Silent retry on minor connection issues
            pass
            
        time.sleep(3)
    
    # 3. Get Results
    try:
        task_info = requests.get(f"{API_BASE_URL}/get-task?task_id={task_id}", headers=headers).json()
        
        # Extract data from output["string"] as requested
        output = task_info.get("output", {})
        result_string = output.get("string")
        
        if result_string:
            return result_string
        else:
            return json.dumps(task_info, ensure_ascii=False)
    except Exception as e:
        print(f"Error: Failed to retrieve results - {e}")
        return None

if __name__ == "__main__":
    # Prioritize command line API key, then environment variable
    [REDACTED_SECRET]"BROWSERACT_API_KEY")
    
    if len(sys.argv) < 2:
        print("Usage: python google_maps_search_api.py <keywords> [language] [country] [max_dates]")
        sys.exit(1)
        
    if not [REDACTED_SECRET]"\n[!] ERROR: BrowserAct API Key is missing.")
        print("Please follow these steps:")
        print("1. Go to: https://www.browseract.com/reception/integrations")
        print("2. Copy your API Key.")
        print("3. Provide it to me or set it as an environment variable (BROWSERACT_API_KEY).")
        sys.exit(1)
        
    keywords = sys.argv[1]
    language = sys.argv[2] if len(sys.argv) > 2 else "en"
    country = sys.argv[3] if len(sys.argv) > 3 else "us"
    max_dates = sys.argv[4] if len(sys.argv) > 4 else 100
    
    result = run_google_maps_task(api_key, keywords, language, country, max_dates)
    if result:
        print(result)


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)