做电商最痛苦的不是没流量,是不知道用户为什么不买。我开发了一套系统:用SerpBase采集竞品的搜索结果,提取评论数据,再用NLP做情感分析。这篇文章分享如何用低成本方案做竞品口碑情报。

一、电商评论的价值

用户评论是购买决策的关键因素:

  • 93%的消费者说评论影响他们的购买决定
  • 一个负面评价可能需要12个正面评价来抵消
  • 评论关键词直接影响搜索排名

但手动看几百条评论不现实。自动化方案:搜索API + NLP。

二、采集竞品评论数据

2.1 从搜索结果提取评论信息

import requests
from typing import List, Dict

API_KEY = "YOUR_KEY"
BASE_URL = "https://api.serpbase.dev/google/search"

def find_review_sources(product: str, api_key: str) -> List[Dict]:
    """找到产品的评论来源"""
    
    review_queries = [
        f"{product} review",
        f"{product} customer review",
        f"{product} user feedback",
        f"{product} pros and cons"
    ]
    
    sources = []
    
    for query in review_queries:
        headers = {
            "X-API-Key": api_key,
            "Content-Type": "application/json"
        }
        body = {
            "q": query,
            "hl": "en",
            "gl": "us",
            "page": 1
        }
        
        r = requests.post(BASE_URL, headers=headers, json=body, timeout=30)
        data = r.json()
        
        for item in data.get("organic", []):
            domain = item.get("display_link", "")
            
            # 识别评论平台
            if any(platform in domain for platform in ["amazon.com", "trustpilot.com", "reddit.com", "quora.com"]):
                sources.append({
                    "platform": domain,
                    "title": item.get("title", ""),
                    "url": item.get("link", ""),
                    "snippet": item.get("snippet", "")[:300],
                    "rank": item["rank"]
                })
    
    return sources

2.2 提取评论文本

def extract_reviews_from_search(product: str, api_key: str) -> List[Dict]:
    """从搜索结果摘要中提取评论"""
    
    headers = {
        "X-API-Key": api_key,
        "Content-Type": "application/json"
    }
    body = {
        "q": f"{product} review",
        "hl": "en",
        "gl": "us",
        "page": 1
    }
    
    r = requests.post(BASE_URL, headers=headers, json=body, timeout=30)
    data = r.json()
    
    reviews = []
    
    # 从snippets中提取看起来像评论的文本
    for item in data.get("organic", []):
        snippet = item.get("snippet", "")
        
        # 简单的评论检测:包含情感词的句子
        sentiment_indicators = ["great", "amazing", "terrible", "awful", "love", "hate", "perfect", "disappointed"]
        
        if any(word in snippet.lower() for word in sentiment_indicators):
            reviews.append({
                "text": snippet,
                "source": item.get("display_link", ""),
                "title": item.get("title", "")
            })
    
    return reviews

三、NLP情感分析

from textblob import TextBlob

def analyze_sentiment(reviews: List[Dict]) -> Dict:
    """分析评论情感"""
    
    sentiments = []
    positive_aspects = []
    negative_aspects = []
    
    for review in reviews:
        text = review["text"]
        blob = TextBlob(text)
        
        polarity = blob.sentiment.polarity
        subjectivity = blob.sentiment.subjectivity
        
        sentiments.append({
            "text": text[:200],
            "polarity": polarity,
            "subjectivity": subjectivity,
            "sentiment": "positive" if polarity > 0.1 else "negative" if polarity < -0.1 else "neutral"
        })
        
        # 提取关键词(简化版)
        words = [w.lower() for w in blob.words if len(w) > 3]
        
        if polarity > 0.1:
            positive_aspects.extend(words)
        elif polarity < -0.1:
            negative_aspects.extend(words)
    
    # 统计
    total = len(sentiments)
    positive = sum(1 for s in sentiments if s["sentiment"] == "positive")
    negative = sum(1 for s in sentiments if s["sentiment"] == "negative")
    neutral = sum(1 for s in sentiments if s["sentiment"] == "neutral")
    
    from collections import Counter
    
    return {
        "total_reviews": total,
        "positive": positive,
        "negative": negative,
        "neutral": neutral,
        "positive_ratio": positive / total if total > 0 else 0,
        "avg_polarity": sum(s["polarity"] for s in sentiments) / total if total > 0 else 0,
        "top_positive_words": Counter(positive_aspects).most_common(10),
        "top_negative_words": Counter(negative_aspects).most_common(10)
    }

四、竞品对比分析

def compare_product_sentiment(products: List[str], api_key: str) -> List[Dict]:
    """对比多个产品的口碑"""
    
    comparisons = []
    
    for product in products:
        reviews = extract_reviews_from_search(product, api_key)
        sentiment = analyze_sentiment(reviews)
        
        comparisons.append({
            "product": product,
            "sentiment": sentiment,
            "overall_score": sentiment["positive_ratio"] * 100
        })
    
    # 排序
    comparisons.sort(key=lambda x: x["overall_score"], reverse=True)
    
    return comparisons

五、实战数据

对比了5款项目管理软件:

产品 正面比例 平均情感 主要好评 主要差评
Asana 68% 0.32 界面、协作 价格、学习曲线
Monday 72% 0.38 可视化、模板 移动端、速度
ClickUp 61% 0.21 功能多 复杂、慢
Notion 75% 0.41 灵活、免费 组织混乱
Trello 70% 0.35 简单、直观 功能少

六、总结

电商评论分析的核心:

  1. 自动化采集:用搜索API找到评论来源
  2. NLP分析:TextBlob做基础情感分析
  3. 竞品对比:知道自己的优势和劣势
  4. 关键词挖掘:好评词用于产品描述,差评词用于改进

成本:100次搜索查询,$0.03。比买舆情监控工具便宜100倍。


情感分析用简单的TextBlob就够了,不需要BERT。电商评论通常情感很直接(“great”、“terrible”),简单的词典方法准确率就能到70%+。如果要更准,可以用VADER或训练自己的模型。

Logo

电商企业物流数字化转型必备!快递鸟 API 接口,72 小时快速完成物流系统集成。全流程实战1V1指导,营造开放的API技术生态圈。

更多推荐