安卓机: 批量导入-短信
方式一(我用的荣耀测试机,失败了。 三星手机和OPPO手机可以):下载软件: SMS Backup
使用该软件,备份文件到 本机目录å
将生成的 .xml 文件,传到 本机备份的目录
点击 SMS Backup 左上角的选项 - “恢复” - 选择 “本地备份位置” -- 选择 “选择另一个备份” , 使用 脚本生成的.xml 文件, 点击 “恢复”
方式二:下载 Super Backup(我用的这个)
下载链接:https://filehippo.com/zh/android/download_super-backup-sms-contacts/
备份文件,查看短信备份文件的格式、内容,
根据备份的文件,生成对应的格式和内容文件
将生成的 xml传到 手机中
使用 Super Backup,选择 “还原短信”,使用 脚本生成的 .xml 文件 (注意点:默认应用设置为 Super Backup )
#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@author:Zx
@file: random_sms_content.py
@time: 2025/9/9 17:47
# @describe: 随机短信内容-json 数据
"""
import json
import random
from datetime import datetime, timedelta
def generate_sms_data(num_messages=1000):
# 基础消息模板
message_templates = [
{
"addr": "TELCEL",
"body": "Recarga HOY $50 y recibe 500Mb p/navegar, 1GB para Redes Sociales, ademas Whatsapp ilimitado con videollamadas incluidas por 7 dias. +Info *264",
"type": 1
},
{
"addr": "TELCEL",
"body": "TU LINEA ESTA INACTIVA, REACTIVALA CON $20 Y RECIBE MIN/SMS Y WHATSAPP ILIMITADOS+200 MEGAS P/FB Y TW+100 MEGAS P/INTERNET POR 1 DIA. +INFO *264",
"type": 1
},
{
"addr": "TELCEL",
"body": "Recarga HOY $50 y recibe 500 MB p/navegar, 1 GB para Redes Sociales, ademas Whatsapp ilimitado con videollamadas incluidas por 7 dias. Info *264",
"type": 1
},
{
"addr": "TELCEL",
"body": "Promocion ESPECIAL: $30 por 300MB + WhatsApp ilimitado por 24 horas. Aprovecha ahora! *264#",
"type": 1
},
{
"addr": "TELCEL",
"body": "Por tu cumpleanos te regalamos 500MB gratis! Usalos en las proximas 24 horas. Felicidades!",
"type": 1
},
{
"addr": "MOVISTAR",
"body": "Bienvenido a MOVISTAR! Disfruta de nuestras promociones especiales. *111# para mas info",
"type": 1
},
{
"addr": "AT&T",
"body": "AT&T te ofrece doble datos este fin de semana. Recarga $100 y obtén el doble de megas!",
"type": 1
}
]
# 其他可能的发送方
senders = ["TELCEL", "MOVISTAR", "AT&T", "UNEFON", "SERVICIO_CLIENTE"]
sms_data = []
base_timestamp = int(datetime(2024, 1, 1).timestamp() * 1000) # 2024年1月1日作为基准时间
for i in range(num_messages):
# 随机选择消息模板或创建变体
if random.random() < 0.7: # 70%的概率使用模板消息
template = random.choice(message_templates)
message = template.copy()
else:
# 生成随机消息
message = {
"addr": random.choice(senders),
"body": generate_random_message(),
"type": 1
}
# 生成随机时间戳(过去365天内)
random_days = random.randint(0, 365)
random_hours = random.randint(0, 23)
random_minutes = random.randint(0, 59)
random_seconds = random.randint(0, 59)
timestamp = base_timestamp + (
random_days * 24 * 60 * 60 * 1000 +
random_hours * 60 * 60 * 1000 +
random_minutes * 60 * 1000 +
random_seconds * 1000
)
# 随机阅读状态(已读或未读)
read_status = random.choice([0, 1])
# 构建完整消息
sms = {
"addr": message["addr"],
"body": message["body"],
"person": 0,
"read": read_status,
"timestamp": timestamp,
"type": message["type"]
}
sms_data.append(sms)
return sms_data
def generate_random_message():
# 生成随机短信内容
promotions = [
"Oferta ESPECIAL: ",
"Promocion limitada: ",
"Solo por hoy: ",
"Aprovecha esta promocion: ",
"No te lo pierdas: "
]
services = [
"recibe minutos ilimitados",
"obten megas gratis",
"disfruta de WhatsApp ilimitado",
"llamadas sin costo",
"internet a alta velocidad"
]
amounts = ["$20", "$30", "$50", "$100", "$150"]
durations = ["por 1 dia", "por 3 dias", "por 7 dias", "por 15 dias", "por 30 dias"]
data_amounts = ["100MB", "500MB", "1GB", "2GB", "5GB"]
message = (
f"{random.choice(promotions)}"
f"Recarga {random.choice(amounts)} y "
f"{random.choice(services)} "
f"con {random.choice(data_amounts)} "
f"{random.choice(durations)}. "
f"Para mas info marca *{random.randint(100, 999)}#"
)
return message
# 生成1000条数据
sms_messages = generate_sms_data(1000)
# 保存到JSON文件
with open('sms_data_1000.json', 'w', encoding='utf-8') as f:
json.dump(sms_messages, f, ensure_ascii=False, indent=2)
print(f"已生成 {len(sms_messages)} 条短信数据并保存到 sms_data_1000.json")
print("前5条数据示例:")
for i, msg in enumerate(sms_me