Get Safari's Reading List programmatically with Ruby
I wanted to export my Safari Reading List on OS X, so I wrote some code to do it. I leveraged Ruby, but this methodology could be easily ported to other languages like Bash, Python, or Objective C.
First, make sure you have the plist
gem:
gem install plist
Then fetch Safari’s Reading List:
require "plist"
begin
bookmarks_xml = `plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist`
urls = Plist.parse_xml(bookmarks_xml)["Children"].select{|e|e["Title"]=="com.apple.ReadingList"}[0]["Children"].map{|e|e["URLString"]}
puts urls
rescue NoMethodError => e
puts "Your reading list is empty."
end
This snippet is just a starting point; feel free to customize it for your specific use case.