项目作者: mazen160

项目描述 :
WhatsApp Chat Parser
高级语言: Python
项目地址: git://github.com/mazen160/whatsapp-chat-parser.git
创建时间: 2020-05-31T14:55:54Z
项目社区:https://github.com/mazen160/whatsapp-chat-parser

开源协议:MIT License

下载


whatsapp-chat-parser

A module to parse WhatsApp chats

Use-Cases?

  • Analysis of WhatsApp messages for different domain-specific motives.
  • Processing WhatsApp messages.
  • Having an interface for reading raw WhatsApp chat exports.

Usage

Installing module

  1. python3 setup.py install

Running the module

  1. from whatsapp_chat_parser import get_messages
  2. messages = get_messages("chat.txt")
  3. for message in messages["chats"]:
  4. print(message["author"])
  5. print(message["message"])
  6. print(message["timestamp"])
  7. for descriptive_message in messages["descriptive_messages"]:
  8. print(descriptive_message)

API

  1. >>> messages = whatsapp_chat_parser.get_messages("chat.txt") # Parameters: path of the chat txt file, and an optional (date_format) string (default date_format: [%d/%m/%Y, %H:%M:%S])
  2. >>> messages["chats"] # Chats, ordered by timestamp.
  3. >>> for message in messages["chats"]:
  4. >>> message["chats"]["timestamp"] # Timestamp in datetime
  5. >>> message["chats"]["original_date"] # Original timestamp
  6. >>> message["chats"]["message"] # Message
  7. >>> message["chats"]["Author"] # Author
  8. >>> message["descriptive_messages"] # List of descriptive messages that was sent by WhatsApp, ordered by timestamp.

Examples

The ./examples directory has CLI examples.

  1. $ python parse_chat.py
  2. -::: parse-chat.py (for whatsapp-chat-parser) :::-
  3. -::: by: Mazin Ahmed (mazin[at]mazinahmed.net) :::-
  4. Usage parse_chat.py [_chat.txt]
  1. $ python get_author_count.py
  2. 25000 --> X
  3. 30 --> Y
  4. 1 --> Z

Exporting Chats

Exporting chats is done from the WhatsApp app. You can follow WhatsApp documentation for the details.

https://faq.whatsapp.com/en/android/23756533/.

Requirements

  • Python 3

License

The project is licensed under MIT License.

Author

Mazin Ahmed