Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How do I export my safari 5.1 Reading list?

Does anyone know how to export an iMac's Safari 5.1 reading list to a Macbook Pro (with Safari 5.1 too)?


Thank You in advance

Safari 5.1-OTHER, Mac OS X (10.6.8)

Posted on Aug 4, 2011 10:22 AM

Reply
17 replies

Mar 28, 2016 1:11 PM in response to ImprovingApple

If you had tested this before you posted, you would realize that it returns far more links than one has in their Reading List — at least when run on OS X El Capitan 10.11.4. I have 8 items in my reading list and this command returned dozens of links.


However, I can say with certainty that the following Python script only looks at Reading list items, and prints their title and URL together. If you are using Sublime Text 3, you can copy and then use Paste and Indent. If TextEdit, choose Make Plain Text from the Format menu before copy/paste. Note: Python code must have one blank line at end. Save as rl.py.


Usage in Terminal:

# make it user executable.

$ chmod +x rl.py

#three possible invocations:

$ rl.py

$ rl.py > rl.txt

$ rl.py | open -f -a TextEdit


Python source:

#!/usr/bin/python

# coding: utf-8



# Read the Safari Bookmarks.plist file and output only ReadingList

# items as page title, URL couplets.

# Tested on Yosemite and El Capitan with standard System Python

# VikingOSX, March 28, 2016, Apple Support Communities



import os

import sys

import subprocess

import plistlib



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





def main():

# Read and parse the bookmarks file as a subprocess into a pipe

pipe = (subprocess.Popen(('/usr/bin/plutil', '-convert', 'xml1', '-o',

'-', BFILE), shell=False, stdout=subprocess.PIPE).stdout)



xml = plistlib.readPlist(pipe)

pipe.close()



section = (filter(lambda record: 'com.apple.ReadingList' ==

record.get('Title'), xml['Children']))



reading_list = section[0].get('Children')



if None in reading_list:

reading_list = []

sys.exit('Nothing found in Safari Reading List')



for item in reading_list:

print("{}\n{}\n".format(item['URIDictionary']['title']

.encode('utf-8'), item['URLString']))



if __name__ == '__main__':

sys.exit(main())

Original Python formatting:

User uploaded file

Apr 9, 2016 7:10 PM in response to VikingOSX

This is much better. Additionally, I noticed that the output of ImprovingApple's script is not in chronological order, which is not useful as a reading list in my mind. One caution to users trying this: cutting and pasting from this screen to a text file introduces whitespace that python doesn't like - not only spaces but some other invisible character, probably non-breaking spaces. If you are getting syntax error after line 3, this is the problem.


I fixed this using Atom editor by searching for whitespace with this regular expression: \w which selects spaces and nonbreaking spaces, and replace them all with [ ] (a space). Now that they are all actual spaces, I searched for [ ]{4} (groups of 4 spaces) and replaced them with \t (tab). Then python was happy. Anywhere it chokes after this procedure just means there are stray spaces before lines that the above did not catch.

How do I export my safari 5.1 Reading list?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.