Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Export Safari Reading List bookmarks to pinboard
#!/usr/bin/env python
forked from
Requires Python 3.
import os
import plistlib
INPUT_FILE = os.path.join(os.environ['HOME'], 'Library/Safari/Bookmarks.plist')
OUTPUT_FILE = 'readinglist.html'
# Load and parse the Bookmarks file
with open(INPUT_FILE, 'rb') as plist_file:
plist = plistlib.load(plist_file)
# Look for the child node which contains the Reading List data.
# There should only be one Reading List item
children = plist['Children']
for child in children:
if child.get('Title', None) == '':
reading_list = child
# Extract the bookmarks
bookmarks = reading_list['Children']
# For each bookmark in the bookmark list, grab the URL
urls = ('<dt><a href="' + bookmark['URLString'] + '">' + bookmark['URIDictionary']['title'] + '</a>' for bookmark in bookmarks)
# Write the URLs to a file
with open(OUTPUT_FILE, 'w') as outfile:
outfile.write('<DT><H3 FOLDED>Reading List (exported)</H3>\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment