Skip to content

Instantly share code, notes, and snippets.

@mastier
Created March 12, 2018 22:38
Show Gist options
  • Save mastier/f95a139b1b4d66e8db39fcf5376508be to your computer and use it in GitHub Desktop.
Save mastier/f95a139b1b4d66e8db39fcf5376508be to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# very crude but works ;-)
import bs4
import base64
bs4.BeautifulSoup(open('sms.xml'), 'lxml-xml')
parts=bs.findAll('part')
for part in parts:
if part.parent.parent.findAll('addr', attrs={'address':'+48XXXXXXXXXX'}):
if part.attrs['ct'] not in ('text/plain', 'application/smil'):
open('extracted/{}'.format(part.attrs['cl']), 'wb').write(base64.decodestring(part.attrs['data'].encode('ascii')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment