How to get Reading List items as links

I whipped up a Python script to read the plist file referenced in the question patrix mentioned in the comments.

#!/usr/bin/env python
import plistlib
from shutil import copy
import subprocess
import os
from tempfile import gettempdir
import sys
import atexit

BOOKMARKS_PLIST = '~/Library/Safari/Bookmarks.plist'
bookmarksFile = os.path.expanduser(BOOKMARKS_PLIST)

# Make a copy of the bookmarks and convert it from a binary plist to text
tempDirectory = gettempdir()
copy(bookmarksFile, tempDirectory)
bookmarksFileCopy = os.path.join(tempDirectory, os.path.basename(bookmarksFile))

def removeTempFile():
    os.remove(bookmarksFileCopy)

atexit.register(removeTempFile) # Delete the temp file when the script finishes

converted = subprocess.call(['plutil', '-convert', 'xml1', bookmarksFileCopy])

if converted != 0:
    print "Couldn't convert bookmarks plist from xml format"
    sys.exit(converted)

plist = plistlib.readPlist(bookmarksFileCopy)
 # There should only be one Reading List item, so take the first one
readingList = [item for item in plist['Children'] if 'Title' in item and item['Title'] == 'com.apple.ReadingList'][0]

if 'Children' in readingList:
    for item in readingList['Children']:
        print item['URLString']

Copy and paste that into a file, name it something like readinglisturls.py. Then make it executable by running chmod +x readinglisturls.py in the Terminal. Then you can run it in the Terminal and it will print out any Reading List URLs. If you want the URLs in a file, you can redirect the output to a file by running /path/to/readinglisturls.py > myfile.txt in the Terminal.


Another option using the plist Ruby gem:

sudo gem install plist;plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist|ruby -rubygems -e 'require "plist";puts Plist.parse_xml(STDIN.read)["Children"].select{|e|e["Title"]=="com.apple.ReadingList"}[0]["Children"].map{|e|e["URLString"]}'

Or if you don't have other bookmarks:

defaults read ~/Library/Safari/Bookmarks.plist | sed -En 's/^ *URLString = "(.*)";/\1/p'