This script allows you to transform HTML files that contain chat messages into a text file formatted like a WhatsApp chat.
Download and install Python from the official website. Follow the instructions for your operating system.
Open your command prompt (Windows) or terminal (macOS/Linux) and run the following command to install the BeautifulSoup library:
pip install beautifulsoup4
Save the provided script into a file named transform_html_to_whatsapp.py
.
Ensure your chat messages are saved in an HTML file (e.g., messages.html
).
Open Command Prompt or Terminal
Win + R
, type cmd
, and press Enter.Navigate to the Directory Containing the Script and HTML File
Use the cd
command to change the directory to where you saved transform_html_to_whatsapp.py
and messages.html
.
cd path/to/your/directory
Run the Script
Execute the script by running:
python transform_html_to_whatsapp.py
Wait for the Script to Complete
The script will read your HTML file, transform the content, and save it to _chat.txt
. You will see a message indicating the transformation is complete.
Here is a detailed example of the commands you might run:
pip install beautifulsoup4
cd C:\Users\YourUsername\Documents\YourDirectory # Navigate to your directory
python transform_html_to_whatsapp.py # Run the script
After running the script, you'll find a file named _chat.txt
in the same directory. This file contains the transformed chat messages in WhatsApp format.
pip install beautifulsoup4
command.ls
(macOS/Linux) or dir
(Windows) command to list files in the current directory to verify.python --version
.