ScavioScavio
ProductoPreciosDocumentación
Iniciar sesionComenzar
  1. Inicio
  2. Tutoriales
  3. Cómo crear un agente de seguimiento de sentimientos de Reddit para palabras clave de marca
Tutorial

Cómo crear un agente de seguimiento de sentimientos de Reddit para palabras clave de marca

Cree un agente que rastree el sentimiento de Reddit sobre las palabras clave de la marca. Obtenga publicaciones a través de Scavio, clasifique opiniones y genere informes de opiniones diarios.

Obtener clave API gratisDocumentacion API

Las discusiones de Reddit contienen opiniones sin filtrar sobre productos, marcas e industrias que las encuestas y los sitios de reseñas pasan por alto. Hacer un seguimiento manual de las opiniones en los subreddits no es práctico: los hilos se mueven rápidamente y abarcan cientos de comunidades. Este tutorial crea un agente de Python que utiliza la API de Scavio para buscar en Reddit publicaciones relacionadas con la marca, aplica un clasificador de opiniones simple basado en palabras clave y agrega los resultados en un informe diario con puntuación de opinión general, hilos positivos principales, hilos negativos principales y preocupaciones de tendencia. El enfoque no utiliza modelos de aprendizaje automático, solo puntuación de palabras clave ponderadas por expresiones regulares que se ejecuta instantáneamente y no cuesta nada más allá de las llamadas a la API.

Requisitos previos

  • Python 3.8 o superior instalado
  • solicita biblioteca instalada
  • Una clave API de Scavio de scavio.dev
  • Palabras clave de marca o nombres de productos para realizar un seguimiento

Guia paso a paso

Paso 1: Definir palabras clave de marca y léxico de sentimientos

Configure los términos de marca a buscar y un léxico de palabras clave ponderado simple para la clasificación de sentimientos. Las palabras positivas y negativas tienen cada una una puntuación.

Python
BRAND_QUERIES = [
    "scavio api",
    "scavio search",
    "scavio mcp"
]

POSITIVE_WORDS = ["love", "great", "fast", "reliable", "cheap", "easy", "best", "solid", "recommend", "impressed"]
NEGATIVE_WORDS = ["slow", "expensive", "broken", "hate", "worst", "terrible", "buggy", "unreliable", "scam", "overpriced"]

Paso 2: Obtenga publicaciones de Reddit a través de la API de Scavio

Busque en Reddit a través del punto final de Scavio usando el parámetro de plataforma. Recopile el título de la publicación, el fragmento, el enlace y el subreddit de cada resultado.

Python
import os
import requests

API_KEY = os.environ.get("SCAVIO_API_KEY", "your_scavio_api_key")

def search_reddit(query: str) -> list[dict]:
    r = requests.post(
        "https://api.scavio.dev/api/v1/search",
        headers={"x-api-key": API_KEY},
        json={"query": query, "platform": "reddit"}
    )
    r.raise_for_status()
    return r.json().get("organic_results", [])

Paso 3: Puntuación de sentimiento para cada publicación

Aplique el léxico de palabras clave al título y fragmento de cada publicación. Sume las visitas positivas y negativas para producir una puntuación de sentimiento neta por publicación.

Python
def score_sentiment(text: str) -> dict:
    text_lower = text.lower()
    pos = sum(1 for w in POSITIVE_WORDS if w in text_lower)
    neg = sum(1 for w in NEGATIVE_WORDS if w in text_lower)
    net = pos - neg
    if net > 0:
        label = "positive"
    elif net < 0:
        label = "negative"
    else:
        label = "neutral"
    return {"positive": pos, "negative": neg, "net": net, "label": label}

def analyze_post(post: dict) -> dict:
    text = f"{post.get('title', '')} {post.get('snippet', '')}"
    sentiment = score_sentiment(text)
    return {
        "title": post.get("title", ""),
        "link": post.get("link", ""),
        "subreddit": post.get("source", ""),
        "sentiment": sentiment
    }

Paso 4: Generar el informe de sentimiento diario

Agregue sentimientos en todas las publicaciones, identifique los principales temas positivos y negativos y escriba un informe resumido.

Python
import json
from datetime import date

def generate_report(brand_queries: list[str]) -> dict:
    all_posts = []
    for query in brand_queries:
        results = search_reddit(query)
        analyzed = [analyze_post(p) for p in results]
        all_posts.extend(analyzed)
    total = len(all_posts)
    positive = [p for p in all_posts if p["sentiment"]["label"] == "positive"]
    negative = [p for p in all_posts if p["sentiment"]["label"] == "negative"]
    neutral = [p for p in all_posts if p["sentiment"]["label"] == "neutral"]
    report = {
        "date": str(date.today()),
        "total_posts": total,
        "positive": len(positive),
        "negative": len(negative),
        "neutral": len(neutral),
        "sentiment_ratio": round(len(positive) / total, 2) if total else 0,
        "top_positive": sorted(positive, key=lambda p: p["sentiment"]["net"], reverse=True)[:3],
        "top_negative": sorted(negative, key=lambda p: p["sentiment"]["net"])[:3]
    }
    with open(f"reddit_sentiment_{report['date']}.json", "w") as f:
        json.dump(report, f, indent=2)
    print(f"Report: {total} posts, {len(positive)} positive, {len(negative)} negative")
    return report

generate_report(BRAND_QUERIES)

Ejemplo en Python

Python
import os
import json
import requests
from datetime import date

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

POSITIVE = ["love", "great", "fast", "reliable", "cheap", "easy", "best", "solid", "recommend", "impressed"]
NEGATIVE = ["slow", "expensive", "broken", "hate", "worst", "terrible", "buggy", "unreliable", "scam", "overpriced"]

def search_reddit(query: str) -> list[dict]:
    r = requests.post(
        ENDPOINT,
        headers={"x-api-key": API_KEY},
        json={"query": query, "platform": "reddit"}
    )
    r.raise_for_status()
    return r.json().get("organic_results", [])

def score(text: str) -> dict:
    t = text.lower()
    pos = sum(1 for w in POSITIVE if w in t)
    neg = sum(1 for w in NEGATIVE if w in t)
    net = pos - neg
    label = "positive" if net > 0 else "negative" if net < 0 else "neutral"
    return {"pos": pos, "neg": neg, "net": net, "label": label}

def track_sentiment(queries: list[str]) -> dict:
    posts = []
    for q in queries:
        for result in search_reddit(q):
            text = f"{result.get('title', '')} {result.get('snippet', '')}"
            posts.append({
                "title": result.get("title", ""),
                "link": result.get("link", ""),
                "sentiment": score(text)
            })
    total = len(posts)
    pos_count = sum(1 for p in posts if p["sentiment"]["label"] == "positive")
    neg_count = sum(1 for p in posts if p["sentiment"]["label"] == "negative")
    report = {
        "date": str(date.today()),
        "total": total,
        "positive": pos_count,
        "negative": neg_count,
        "neutral": total - pos_count - neg_count,
        "ratio": round(pos_count / total, 2) if total else 0,
        "top_positive": sorted([p for p in posts if p["sentiment"]["label"] == "positive"],
                               key=lambda x: x["sentiment"]["net"], reverse=True)[:3],
        "top_negative": sorted([p for p in posts if p["sentiment"]["label"] == "negative"],
                               key=lambda x: x["sentiment"]["net"])[:3]
    }
    output = f"reddit_sentiment_{report['date']}.json"
    with open(output, "w") as f:
        json.dump(report, f, indent=2)
    print(f"{total} posts: {pos_count} positive, {neg_count} negative")
    return report

if __name__ == "__main__":
    track_sentiment(["scavio api", "scavio search"])

Ejemplo en JavaScript

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

const POSITIVE = ["love", "great", "fast", "reliable", "cheap", "easy", "best", "solid", "recommend"];
const NEGATIVE = ["slow", "expensive", "broken", "hate", "worst", "terrible", "buggy", "unreliable"];

async function searchReddit(query) {
  const res = await fetch(ENDPOINT, {
    method: "POST",
    headers: { "x-api-key": API_KEY, "Content-Type": "application/json" },
    body: JSON.stringify({ query, platform: "reddit" })
  });
  const data = await res.json();
  return data.organic_results || [];
}

function score(text) {
  const t = text.toLowerCase();
  const pos = POSITIVE.filter(w => t.includes(w)).length;
  const neg = NEGATIVE.filter(w => t.includes(w)).length;
  const net = pos - neg;
  return { pos, neg, net, label: net > 0 ? "positive" : net < 0 ? "negative" : "neutral" };
}

async function trackSentiment(queries) {
  const posts = [];
  for (const q of queries) {
    const results = await searchReddit(q);
    for (const r of results) {
      const text = `${r.title || ""} ${r.snippet || ""}`;
      posts.push({ title: r.title, link: r.link, sentiment: score(text) });
    }
  }
  const pos = posts.filter(p => p.sentiment.label === "positive").length;
  const neg = posts.filter(p => p.sentiment.label === "negative").length;
  console.log(`${posts.length} posts: ${pos} positive, ${neg} negative`);
  const today = new Date().toISOString().split("T")[0];
  fs.writeFileSync(`reddit_sentiment_${today}.json`, JSON.stringify({ date: today, total: posts.length, positive: pos, negative: neg }, null, 2));
}

trackSentiment(["scavio api", "scavio search"]).catch(console.error);

Salida esperada

JSON
{
  "date": "2026-05-17",
  "total": 24,
  "positive": 9,
  "negative": 4,
  "neutral": 11,
  "ratio": 0.38,
  "top_positive": [
    {
      "title": "Scavio is the best cheap alternative to SerpApi",
      "link": "https://reddit.com/r/webdev/comments/abc123",
      "sentiment": { "pos": 2, "neg": 0, "net": 2, "label": "positive" }
    }
  ],
  "top_negative": [
    {
      "title": "Any search APIs that are not slow and overpriced?",
      "link": "https://reddit.com/r/artificial/comments/def456",
      "sentiment": { "pos": 0, "neg": 2, "net": -2, "label": "negative" }
    }
  ]
}

Tutoriales relacionados

  • Cómo crear un rastreador de sentimientos de Reddit
  • Cómo analizar el sentimiento de Reddit con un LLM
  • Cómo crear un escáner de demanda de Reddit con filtrado de actualidad

Preguntas frecuentes

La mayoria de los desarrolladores completan este tutorial en 15 a 30 minutos. Necesitaras una clave API de Scavio (el plan gratuito funciona) y un entorno de Python o JavaScript.

Python 3.8 o superior instalado. solicita biblioteca instalada. Una clave API de Scavio de scavio.dev. Palabras clave de marca o nombres de productos para realizar un seguimiento. Una clave API de Scavio te da 50 creditos gratuitos al registrarte.

Si. El plan gratuito incluye 50 creditos al registrarte, mas que suficiente para completar este tutorial y crear un prototipo funcional.

Scavio tiene un paquete nativo de LangChain (langchain-scavio), un servidor MCP y una API REST simple que funciona con cualquier cliente HTTP. Este tutorial usa the raw REST API, pero puedes adaptarlo al framework que prefieras.

Recursos relacionados

Best Of

Las mejores API de Reddit para datos de sentimiento bursátil en 2026

Read more
Best Of

Mejor API de Reddit en 2026

Read more
Glossary

Panorama de proveedores de API de búsqueda (2026)

Read more
Solution

Descubrimiento de demanda de Reddit para fundadores

Read more
Solution

Datos de Reddit sin API directa

Read more
Comparison

Reddit API / Search API vs Social Listening Tools (Brandwatch, Mention, Sprout Social)

Read more

Empieza a construir

Cree un agente que rastree el sentimiento de Reddit sobre las palabras clave de la marca. Obtenga publicaciones a través de Scavio, clasifique opiniones y genere informes de opiniones diarios.

Obtener clave API gratuitaLeer la documentacion
ScavioScavio

API de busqueda en tiempo real para agentes de IA. Busca en todas las plataformas, no solo en Google.

Producto

  • Funciones
  • Precios
  • Panel
  • Afiliados

Desarrolladores

  • Documentacion
  • Referencia de API
  • Inicio rapido
  • Integracion MCP
  • Python SDK

Alternativas

  • Alternativa a Tavily
  • Alternativa a SerpAPI
  • Alternativa a Firecrawl
  • Alternativa a Exa

Herramientas

  • Formateador JSON
  • cURL a codigo
  • Contador de tokens
  • Todas las herramientas

© 2026 Scavio. Todos los derechos reservados.

Featured on TAAFT
Terminos de servicioPolitica de privacidad