Last active
March 4, 2024 22:26
-
-
Save casebeer/4892e839f1f17fd84911b530ad99e251 to your computer and use it in GitHub Desktop.
Script for converting GetPocket.com exported HTML to CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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