将whatsapp聊天文件转换为字典或以json格式保存。

whatsapptojson的Python项目详细描述


WhatsApp文本到JSON转换器

将whatsapp聊天文件转换为字典或json格式。

可用于iPhone和Android的导出。一定要提到设备。

安装

pip install whatsapptojson

使用命令行参数

whatsapptojson [OPTIONS]

usage: whatsapptojson [-h] -f FILE -d DEVICE [-s SAVE] [-v]

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  chat text file
  -d DEVICE, --device DEVICE
                        can be 'iphone' or 'android'
  -s SAVE, --save SAVE  path of file/direction to save json, 'default' would
                        be same as text file name in same directory
  -v, --verbose         Verbose (Print output)

使用本机python

whatsapptojson.format()-将已读文本转换为字典

whatsapptojson.format_file()-将文件从文本读取到字典/json

确保正确地提到device属性iphoneandroid

fromwhatsapptojsonimportwhatsapptojson# Converting Text to Dictoutput=whatsapptojson.format(text='string with complete chat data',device='android')# Converting File to dictionary.output=whatsapptojson.format_file(source='source_file_path',device='iphone')# Converting File to dictionary.output=whatsapptojson.format_file(source='source_file_path',device='iphone')### Whatsapp File to Json.whatsapptojson.format_file(source='source_file_path',destination='destination_path.json',device='android')

样本导出

{"attachment_extensions":["pdf","mp4","jpg"],"participants":["sender name 1","sender name 2","sender name n"],"chats":[{"date":"25/03/16 07:03:45 PM","message":"‎Messages to this group are now secured with end-to-end encryption.","type":"whatsapp meta"},{"date":"15/08/17 12:27:34 PM","message":"message for attachment","sender":"sender name","type":"attachment","attachment":{"file_name":"file_name_with.pdf","meta":"8 pages","extention":"pdf"}},{"date":"15/08/17 01:37:28 PM","sender":"sender name","message":"message","type":"conversation"},...]}

聊天中的每一项都可以有“WhatsApp元”或“附件”或“对话”类型。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
tomcat Java条带错误   java OPENTSDB fsck修复程序不更正重复点   java JavaFX在控制器内切换自身的可见性   java maven surefire插件未并行执行运行程序   读取导致Freemarker模板引擎中TemplateException的Java对象   无法使Java库与我的Android应用程序一起工作   安卓 java。lang.IllegalStateException游标   使用Java检索XML文件中的XSL URL和名称   java如何从文本文件集合中提取特定值   电子邮件java mail gmail   java为什么finalize()只被垃圾收集器调用一次?   java方法findViewById(int)对于Json类型是未定义的。蛇形   java在安卓中尝试从brother打印机打印位图时遇到以下异常   java在颤振中支持Kotlin的优势   java从后面编写文本   java制作列表。第一个列表可以有相同的数字,第二个将是价格,尝试制作第三个列表,如果它们是相同的数字,它将添加价格