Skip to content

Instantly share code, notes, and snippets.

@kylemsguy
Forked from dwf/msnlog.py
Last active January 23, 2020 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylemsguy/2dc493b3f78563dbabe1da14dc60c160 to your computer and use it in GitHub Desktop.
Save kylemsguy/2dc493b3f78563dbabe1da14dc60c160 to your computer and use it in GitHub Desktop.
A script that dumps convoluted XML log files from MSN Messenger to readable plaintext.
"""
Simple script I whipped up to dump MSN Messenger logs in XML to a readable
plaintext format. It's not very robust, nor am I sure which versions of MSN
Messenger it's compatible or incompatible with; I just had a specific
conversation I wanted to read, and this was the vehicle to that end.
By David Warde-Farley -- user AT cs dot toronto dot edu (user = dwf)
Updated for Python 3.6 by Kyle Zhou (also former CS student at UofT)
Redistributable under the terms of the 3-clause BSD license
(see http://www.opensource.org/licenses/bsd-license.php for details)
"""
import sys
from xml.dom.minidom import parse
if len(sys.argv) != 2:
print("usage:", sys.argv[0], "<inputfile>", file=sys.stderr)
sys.exit(1)
doml = parse(sys.argv[1])
for message in doml.getElementsByTagName("Message"):
sentDateTime = message.getAttribute("DateTime")
fromNode = message.getElementsByTagName("From")[0]
userNode = fromNode.getElementsByTagName("User")[0]
name = userNode.getAttribute("FriendlyName")
msg = message.getElementsByTagName("Text")[0].firstChild.nodeValue
print(f"[{sentDateTime}] {name} says: {msg}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment