做电商最痛苦的不是没流量是不知道用户为什么不买。我开发了一套系统用SerpBase采集竞品的搜索结果提取评论数据再用NLP做情感分析。这篇文章分享如何用低成本方案做竞品口碑情报。一、电商评论的价值用户评论是购买决策的关键因素93%的消费者说评论影响他们的购买决定一个负面评价可能需要12个正面评价来抵消评论关键词直接影响搜索排名但手动看几百条评论不现实。自动化方案搜索API NLP。二、采集竞品评论数据2.1 从搜索结果提取评论信息importrequestsfromtypingimportList,Dict API_KEYYOUR_KEYBASE_URLhttps://api.serpbase.dev/google/searchdeffind_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[]forqueryinreview_queries:headers{X-API-Key:api_key,Content-Type:application/json}body{q:query,hl:en,gl:us,page:1}rrequests.post(BASE_URL,headersheaders,jsonbody,timeout30)datar.json()foritemindata.get(organic,[]):domainitem.get(display_link,)# 识别评论平台ifany(platformindomainforplatformin[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]})returnsources2.2 提取评论文本defextract_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}rrequests.post(BASE_URL,headersheaders,jsonbody,timeout30)datar.json()reviews[]# 从snippets中提取看起来像评论的文本foritemindata.get(organic,[]):snippetitem.get(snippet,)# 简单的评论检测包含情感词的句子sentiment_indicators[great,amazing,terrible,awful,love,hate,perfect,disappointed]ifany(wordinsnippet.lower()forwordinsentiment_indicators):reviews.append({text:snippet,source:item.get(display_link,),title:item.get(title,)})returnreviews三、NLP情感分析fromtextblobimportTextBlobdefanalyze_sentiment(reviews:List[Dict])-Dict:分析评论情感sentiments[]positive_aspects[]negative_aspects[]forreviewinreviews:textreview[text]blobTextBlob(text)polarityblob.sentiment.polarity subjectivityblob.sentiment.subjectivity sentiments.append({text:text[:200],polarity:polarity,subjectivity:subjectivity,sentiment:positiveifpolarity0.1elsenegativeifpolarity-0.1elseneutral})# 提取关键词简化版words[w.lower()forwinblob.wordsiflen(w)3]ifpolarity0.1:positive_aspects.extend(words)elifpolarity-0.1:negative_aspects.extend(words)# 统计totallen(sentiments)positivesum(1forsinsentimentsifs[sentiment]positive)negativesum(1forsinsentimentsifs[sentiment]negative)neutralsum(1forsinsentimentsifs[sentiment]neutral)fromcollectionsimportCounterreturn{total_reviews:total,positive:positive,negative:negative,neutral:neutral,positive_ratio:positive/totaliftotal0else0,avg_polarity:sum(s[polarity]forsinsentiments)/totaliftotal0else0,top_positive_words:Counter(positive_aspects).most_common(10),top_negative_words:Counter(negative_aspects).most_common(10)}四、竞品对比分析defcompare_product_sentiment(products:List[str],api_key:str)-List[Dict]:对比多个产品的口碑comparisons[]forproductinproducts:reviewsextract_reviews_from_search(product,api_key)sentimentanalyze_sentiment(reviews)comparisons.append({product:product,sentiment:sentiment,overall_score:sentiment[positive_ratio]*100})# 排序comparisons.sort(keylambdax:x[overall_score],reverseTrue)returncomparisons五、实战数据对比了5款项目管理软件产品正面比例平均情感主要好评主要差评Asana68%0.32界面、协作价格、学习曲线Monday72%0.38可视化、模板移动端、速度ClickUp61%0.21功能多复杂、慢Notion75%0.41灵活、免费组织混乱Trello70%0.35简单、直观功能少六、总结电商评论分析的核心自动化采集用搜索API找到评论来源NLP分析TextBlob做基础情感分析竞品对比知道自己的优势和劣势关键词挖掘好评词用于产品描述差评词用于改进成本100次搜索查询$0.03。比买舆情监控工具便宜100倍。情感分析用简单的TextBlob就够了不需要BERT。电商评论通常情感很直接“great”、“terrible”简单的词典方法准确率就能到70%。如果要更准可以用VADER或训练自己的模型。