Skip to content

Instantly share code, notes, and snippets.

@max-arnold
Last active June 25, 2019 07:29
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 max-arnold/c2456e1cbb79789d657b4ee178c71a5e to your computer and use it in GitHub Desktop.
Save max-arnold/c2456e1cbb79789d657b4ee178c71a5e to your computer and use it in GitHub Desktop.
Export Safari Reading List to CSV
#!/usr/bin/env python3
# A script to export (backup) Safari Reading List
import os
import plistlib
with open(os.path.expanduser('~/Library/Safari/Bookmarks.plist'), 'rb') as fp:
plist = plistlib.load(fp)
bookmarks = [
ch['Children'] for ch in plist['Children']
if ch.get('Title', None) == 'com.apple.ReadingList'
][0]
urls = (
(
b['ReadingList']['DateAdded'].strftime('%Y-%m-%d %H:%M:%S'),
b['URLString'],
'"' + b['URIDictionary']['title'] + '"'
) for b in bookmarks
)
for u in sorted(urls):
print(', '.join(u))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment