Skip to content

Instantly share code, notes, and snippets.

@casebeer
Last active March 4, 2024 22:26
Show Gist options
  • Save casebeer/4892e839f1f17fd84911b530ad99e251 to your computer and use it in GitHub Desktop.
Save casebeer/4892e839f1f17fd84911b530ad99e251 to your computer and use it in GitHub Desktop.
Script for converting GetPocket.com exported HTML to CSV
'''
Script for converting GetPocket.com exported HTML to CSV
Export data via https://getpocket.com/export
'''
import csv
import sys
import xml.etree.ElementTree as ET
def main():
try:
tree = ET.parse(sys.argv[1])
root = tree.getroot()
except:
root = ET.fromstring(sys.stdin.read())
#import code
#code.interact(local=locals())
f = csv.writer(sys.stdout)
for elt in root.iterfind('.//li/a'):
line = [ elt.get('time_added'), elt.text, elt.get('href'), elt.get('tags') ]
f.writerow(line)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment