Skill: ccmagia2-gif/wechat-article-search-api-skill (version 1.0.1)

--- name: wechat-article-search-api-skill description: "This skill helps users extract full article contents from WeChat using the BrowserAct API. The Agent should proactively apply this skill when users express needs like finding full WeChat articles for specific keywords, tracking WeChat public accounts for industry trends, extracting WeChat article contents for media research, monitoring public relations on WeChat platforms, collecting competitor updates from WeChat, getting full article body from WeChat links, monitoring brand exposure on WeChat articles, retrieving structured WeChat data for sentiment analysis, summarizing daily news from WeChat, getting author and publication date for WeChat articles, or automating WeChat content extraction without scraping." metadata: {"clawdbot":{"emoji":"🌐","requires":{"bins":["python"],"env":["BROWSERACT_API_KEY"]}}} --- # WeChat Article Search API ## 📖 Introduction This skill provides users with automated WeChat article extraction through the BrowserAct WeChat Article Search API template. It allows for the direct extraction of full-content, structured WeChat articles based on keyword searches. Simply provide search keywords and optional date filters, and you can obtain comprehensive article data including the full body text. ## ✨ Features 1. **No hallucinations, ensuring stable and precise data extraction**: Pre-configured workflows avoid AI-generated hallucinations. 2. **No CAPTCHA issues**: No need to handle reCAPTCHA or other verification challenges. 3. **No IP restrictions or geo-blocking**: No need to handle regional IP limitations. 4. **Faster execution**: Task execution is faster compared to pure AI-driven browser automation solutions. 5. **Extremely high cost-effectiveness**: Significantly reduces data acquisition costs compared to AI solutions that consume a large number of tokens. ## 🔑 API Key Guidance Flow Before running, check the `BROWSERACT_API_KEY` environment variable. If not set, do not take other actions; request and wait for the user to provide it. **The Agent must inform the user**: > "Since you have not configured the BrowserAct API Key, please go to the [BrowserAct Console](https://www.browseract.com/reception/integrations) to get your Key." ## 🛠️ Input Parameters When invoking the script, the Agent should flexibly configure the following parameters based on user needs: 1. **keywords (Search Keywords)** - **Type**: `string` - **Description**: Search keywords used to find WeChat articles. Can be an industry term, topic, or specific phrase. - **Example**: `openclaw`, `AI agent`, `browser automation` 2. **Date_limit (Extraction Limit)** - **Type**: `number` - **Description**: Maximum number of articles to extract. For the first run, a smaller default value is recommended. - **Default Value**: `10` - **Suggestions**: Use `5` to `10` for quick testing, larger numbers for batch research. 3. **publication_date (Publication Date Filter)** - **Type**: `string` - **Description**: Filter articles by their publication date. - **Example**: `3月11日`, `March 10`, `2026-03-11` ## 🚀 Invocation Method The Agent should execute the following independent script to achieve "one command, direct results": ```bash # Example invocation python -u ./scripts/wechat_article_search_api.py "keywords" limit "publication_date" ``` ### ⏳ Run Status Monitoring Because this task involves automated browser operations, it may take a long time (several minutes). While running, the script will **continuously output timestamped status logs** (e.g., `[14:30:05] Task Status: running`). **Agent Instructions**: - Keep monitoring the terminal output while waiting for the script to return results. - As long as the terminal continues to output new status logs, it means the task is running normally; do not misjudge it as deadlocked or unresponsive. - Only consider triggering the retry mechanism if the status remains unchanged for a long time, or the script stops outputting without returning results. ## 📊 Output Data Explanation Upon successful execution, the script will parse and print the results directly from the API response. The results include: - `url_link`: Original article URL - `publication_date`: Article publication date - `author`: Article author or publishing account name - `image_url`: Main image URL or article cover image URL - `body_content`: Full body content of the article - `title`: Full article title ## ⚠️ Error Handling & Retry During script execution, if an error occurs (such as network fluctuation or task failure), the Agent should follow this logic: 1. **Check the output content**: - If the output **contains** `"Invalid authorization"`, it means the API Key is invalid or expired. In this case, **do not retry**; guide the user to re-check and provide the correct API Key. - If the output **does not contain** `"Invalid authorization"` but the task fails (e.g., output starts with `Error:` or returns an empty result), the Agent should **automatically try to execute the script one more time**. 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. ## 🌟 Typical Use Cases 1. **Content Monitoring**: Track mentions of specific brands or topics across WeChat articles. 2. **Media Research**: Analyze full text of articles published by top WeChat accounts. 3. **Trend Tracking**: Collect articles about rising industry trends (e.g., AI agents) for comprehensive reading. 4. **Knowledge Base Building**: Extract deep-dive articles into an internal repository. 5. **Competitor Analysis**: Review full-length posts released by competitor accounts.

path: scripts/wechat_article_search_api.py
content: import os
import time
import requests
import json
import sys
import datetime
import io

# Force UTF-8 encoding for standard output and error streams
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')

# API Configuration
TEMPLATE_ID = "84396171023358338"
API_BASE_URL = "https://api.browseract.com/v2/workflow"

def run_wechat_article_search_task(api_key, keywords, limit=10, publication_date="3月11日"):
    headers = {"Authorization": f"Bearer {api_key}"}
    payload = {
        "workflow_template_id": TEMPLATE_ID,
        "input_parameters": [
            {"name": "keywords", "value": keywords},
            {"name": "Date_limit", "value": str(limit)},
            {"name": "publication_date", "value": publication_date}
        ]
    }

    # 1. Start Task
    print(f"Start Task", flush=True)
    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}", flush=True)
        return None

    if "id" not in res:
        print(f"Error: Could not start task. Response: {res}", flush=True)
        return None
    
    task_id = res["id"]
    print(f"Task started. ID: {task_id}", flush=True)
    
    # 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")
            
            timestamp = datetime.datetime.now().strftime("%H:%M:%S")
            print(f"[{timestamp}] Task Status: {status}", flush=True)
            
            if status == "finished":
                print(f"[{timestamp}] Task finished successfully.", flush=True)
                break
            elif status in ["failed", "canceled"]:
                print(f"Error: Task {status}. Please check your BrowserAct dashboard.", flush=True)
                return None
        except Exception as e:
            timestamp = datetime.datetime.now().strftime("%H:%M:%S")
            print(f"[{timestamp}] Polling error: {e}. Retrying...", flush=True)
            
        time.sleep(10)
    
    # 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
        # Usually task_info['output']['string'] contains the result
        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}", flush=True)
        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 wechat_article_search_api.py <keywords> [limit] [publication_date]", flush=True)
        sys.exit(1)
        
    if not [REDACTED_SECRET]"\n[!] ERROR: BrowserAct API Key is missing.", flush=True)
        print("Please follow these steps:", flush=True)
        print("1. Go to: https://www.browseract.com/reception/integrations", flush=True)
        print("2. Copy your API Key.", flush=True)
        print("3. Provide it to me or set it as an environment variable (BROWSERACT_API_KEY).", flush=True)
        sys.exit(1)
        
    keywords = sys.argv[1]
    limit = sys.argv[2] if len(sys.argv) > 2 else 10
    publication_date = sys.argv[3] if len(sys.argv) > 3 else "3月11日"
    
    result = run_wechat_article_search_task(api_key, keywords, limit, publication_date)
    if result:
        print(result, flush=True)


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