How I exported 919 links from my Safari Reading List automatically
Harnessing ChatGPT to Bypass Manual Export: My Automation Process for Safari Reading List
I have captured 919 links to my Safari Reading List. Since full search across all articles is not possible within Safari Reading List I decided to export my links to Raindrop. Additionally, I imported the links into GoodLinks because GoodLinks has a great way of exporting articles in the PDF and Markdown format. Unfortunately, links in Safari Reading List cannot be exported easily. However, I figured out a way of doing it automatically and not manually importing every article into Raindrop and GoodLinks. Make sure you have Python installed.
Here’s the step by step process I employed to export the links from Safari Reading List and import them to Raindrop and GoodLinks:
I closed Safari.
I opened Finder.
To locate the Safari’s Reading List data locally while in Finder I clicked on Go in the menu bar and selected Library.
In Library folder I navigated to Safari folder.
In Safari folder there is a file named `Bookmarks.plist`. This file contains your bookmarks and your reading list.
Using caution, I copied this file. (Be careful not to modify system and application files unless you’re sure about what you’re doing)
I opened my Documents folder.
I created a new folder called `reading_list_urls`
I pasted the Bookmarks.plist file
This type of .plist file can be read with any text editor.
Since the file has a lot of other information related to bookmarks, Reading List items will be a subset of this data in a specific format.
To extract the URLs from the bookmarks.plist file I used Python’s built-in xml parsing and made sure it writes the links into a txt file. Otherwise they are just listed for you in the Terminal.
import plistlib
def extract_reading_list_urls(plist_data):
# Check for dictionary structures in the plist
if isinstance(plist_data, dict):
# Check for the Reading List title
if plist_data.get('Title') == 'com.apple.ReadingList':
for child in plist_data.get('Children', []):
url = child.get('URLString')
if url:
yield url
else:
# Recursively search for reading list entries
for key, value in plist_data.items():
yield from extract_reading_list_urls(value)
# Check for list structures in the plist
elif isinstance(plist_data, list):
for item in plist_data:
yield from extract_reading_list_urls(item)
# Load the plist file
with open('/path_to_your_file/Bookmarks.plist', 'rb') as f:
plist_content = plistlib.load(f)
# Extract the URLs and write to a file
with open('reading_list_urls.txt', 'w') as file:
for url in extract_reading_list_urls(plist_content):
file.write(url + '\n')
Here you could be done because Raindrop can import a txt file if you put one url per line but I wanted to have the links available as bookmarks as well. To do that, I converted the urls from the txt file to HTML Bookmarks format using a Python script. Here’s the ‘Convert the urls to HTML Bookmarks.py’ script:
# Define a template for the bookmarks HTML
HTML_TEMPLATE = """<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file. -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<Title>Bookmarks</Title>
<H1>Bookmarks</H1>
<DL><p>
{bookmarks}
</DL><p>
"""
BOOKMARK_TEMPLATE = """<DT><A HREF="{url}">{url}</A>"""
def convert_txt_to_html(input_file, output_file):
with open(input_file, 'r') as f:
urls = [line.strip() for line in f.readlines()]
bookmarks = "\n ".join([BOOKMARK_TEMPLATE.format(url=url) for url in urls])
with open(output_file, 'w', encoding='utf-8') as f:
f.write(HTML_TEMPLATE.format(bookmarks=bookmarks))
# Convert your URLs
convert_txt_to_html('reading_list_urls.txt', 'bookmarks.html')
In the end I had these files in my folder:
Here’s the shortcut from GoodLinks creator for importing links . You just paste all the links into the first Text action. Make sure to have one link per line.
Hope some of this will be useful to you.