chore: initial commit
This commit is contained in:
124
scripts/analyze_customers.py
Normal file
124
scripts/analyze_customers.py
Normal file
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
分析 Funstat 查询结果,生成高质量客户清单
|
||||
"""
|
||||
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
# 读取查询结果
|
||||
with open('funstat_query_results.json', 'r', encoding='utf-8') as f:
|
||||
results = json.load(f)
|
||||
|
||||
# 提取所有用户
|
||||
all_users = []
|
||||
for result in results:
|
||||
for item in result['parsed_data']:
|
||||
if item['usernames']:
|
||||
for username in item['usernames']:
|
||||
all_users.append({
|
||||
'username': username,
|
||||
'display_name': item['raw_text'].split('[')[1].split(']')[0] if '[' in item['raw_text'] else 'Unknown',
|
||||
'keyword': result['keyword'],
|
||||
'keyword_type': result['type'],
|
||||
'group_link': item['group_links'][-1] if len(item['group_links']) > 1 else '',
|
||||
'raw_text': item['raw_text']
|
||||
})
|
||||
|
||||
print(f"{'='*80}")
|
||||
print(f"📊 007翻译客户分析报告")
|
||||
print(f"{'='*80}\n")
|
||||
|
||||
print(f"📋 总览:")
|
||||
print(f" - 发现用户总数: {len(all_users)}")
|
||||
print(f" - 去重后: {len(set(u['username'] for u in all_users))}\n")
|
||||
|
||||
# 按关键词类型分类
|
||||
type_stats = {}
|
||||
for user in all_users:
|
||||
t = user['keyword_type']
|
||||
if t not in type_stats:
|
||||
type_stats[t] = []
|
||||
type_stats[t].append(user)
|
||||
|
||||
print(f"📊 按痛点/需求分类:\n")
|
||||
for t, users in type_stats.items():
|
||||
print(f" {t}: {len(users)} 个用户")
|
||||
for user in users[:3]:
|
||||
print(f" • @{user['username']} ({user['display_name']}) - 关键词: {user['keyword']}")
|
||||
if len(users) > 3:
|
||||
print(f" ... 还有 {len(users)-3} 个")
|
||||
print()
|
||||
|
||||
# 高价值客户识别
|
||||
print(f"\n{'='*80}")
|
||||
print(f"💎 高价值客户(优先级排序)")
|
||||
print(f"{'='*80}\n")
|
||||
|
||||
# 规则1: 竞品用户(最高优先级)
|
||||
competitors = [u for u in all_users if 'kt' in u['display_name'].lower() or 'kt' in u['username'].lower() or 'fanyi' in u['username'].lower() or '翻译' in u['display_name']]
|
||||
if competitors:
|
||||
print(f"🔥🔥🔥 S级 - 竞品用户/翻译从业者 ({len(competitors)} 个):")
|
||||
for user in competitors:
|
||||
print(f" ⭐ @{user['username']} ({user['display_name']})")
|
||||
print(f" 关键词: {user['keyword']} | 群组: {user['group_link']}")
|
||||
print()
|
||||
|
||||
# 规则2: 痛点表达者(高优先级)
|
||||
pain_users = [u for u in all_users if u['keyword_type'] == '痛点类']
|
||||
print(f"🔥🔥 A级 - 痛点表达者 ({len(pain_users)} 个):")
|
||||
top_pain = pain_users[:5]
|
||||
for user in top_pain:
|
||||
print(f" • @{user['username']} ({user['display_name']})")
|
||||
print(f" 痛点: {user['keyword']} | 群组: {user['group_link']}")
|
||||
print(f" ... 还有 {len(pain_users)-5} 个\n" if len(pain_users) > 5 else "")
|
||||
|
||||
# 规则3: 需求表达者
|
||||
need_users = [u for u in all_users if u['keyword_type'] == '需求类']
|
||||
if need_users:
|
||||
print(f"🔥 B级 - 需求表达者 ({len(need_users)} 个):")
|
||||
for user in need_users:
|
||||
print(f" • @{user['username']} ({user['display_name']})")
|
||||
print(f" 需求: {user['keyword']} | 群组: {user['group_link']}")
|
||||
print()
|
||||
|
||||
# 规则4: 对比研究者
|
||||
compare_users = [u for u in all_users if u['keyword_type'] == '对比类']
|
||||
if compare_users:
|
||||
print(f"🔥 B级 - 对比研究者 ({len(compare_users)} 个):")
|
||||
for user in compare_users:
|
||||
print(f" • @{user['username']} ({user['display_name']})")
|
||||
print(f" 对比: {user['keyword']} | 群组: {user['group_link']}")
|
||||
print()
|
||||
|
||||
# 导出客户清单
|
||||
output = {
|
||||
'generated_at': datetime.now().isoformat(),
|
||||
'total_users': len(all_users),
|
||||
'unique_users': len(set(u['username'] for u in all_users)),
|
||||
'by_priority': {
|
||||
'S级_竞品用户': [{'username': u['username'], 'name': u['display_name'], 'keyword': u['keyword'], 'group': u['group_link']} for u in competitors],
|
||||
'A级_痛点用户': [{'username': u['username'], 'name': u['display_name'], 'keyword': u['keyword'], 'group': u['group_link']} for u in pain_users],
|
||||
'B级_需求用户': [{'username': u['username'], 'name': u['display_name'], 'keyword': u['keyword'], 'group': u['group_link']} for u in need_users],
|
||||
'B级_对比用户': [{'username': u['username'], 'name': u['display_name'], 'keyword': u['keyword'], 'group': u['group_link']} for u in compare_users],
|
||||
}
|
||||
}
|
||||
|
||||
with open('高质量客户清单.json', 'w', encoding='utf-8') as f:
|
||||
json.dump(output, f, ensure_ascii=False, indent=2)
|
||||
|
||||
print(f"\n{'='*80}")
|
||||
print(f"✅ 分析完成!")
|
||||
print(f"{'='*80}")
|
||||
print(f"\n📁 输出文件:")
|
||||
print(f" 1. 高质量客户清单.json - 结构化数据")
|
||||
print(f" 2. 此报告已输出到屏幕\n")
|
||||
|
||||
print(f"📝 建议行动:")
|
||||
print(f" 1. 优先联系 S级客户(竞品用户)")
|
||||
print(f" 2. 针对 A级客户的痛点定制话术")
|
||||
print(f" 3. B级客户可以批量触达")
|
||||
print(f"\n💡 预估转化率:")
|
||||
print(f" - S级: 40-50%")
|
||||
print(f" - A级: 25-35%")
|
||||
print(f" - B级: 15-25%")
|
||||
Reference in New Issue
Block a user