So you've added a bunch of links to the reading list but now you want to get them all at once out as csv?
- open safari on mac
- file export bookmarks
- it will save as Safari Bookmarks.html
- run this python script in that directory
from bs4 import BeautifulSoup
import csv
# Open the Safari Bookmarks HTML file
with open('Safari Bookmarks.html', 'r') as file:
html_content = file.read()
# Parse HTML content
soup = BeautifulSoup(html_content, 'html.parser')
# Find the Reading List section
reading_list_section = soup.find('h3', id='com.apple.ReadingList')
# Check if the Reading List section exists
if reading_list_section:
# Find all links in the Reading List section
links = reading_list_section.find_next_sibling('dl').find_all('a')
# Write links to CSV
with open('reading_list.csv', 'w', newline='', encoding='utf-8') as csvfile:
writer = csv.writer(csvfile)
# Write each link as a row in the CSV without a header
for link in links:
writer.writerow([link.get('href'), link.text.strip()])
else:
print("Reading List section not found in the HTML.")
there's also this one which grabs it from the source
https://github.com/smrfeld/export-safari-reading-list?tab=readme-ov-file
a gotcha for this to generate the website you
- generate the json
- generate the thumbnails folder
- git clone the repo and cd into the website folder
- python3 website.py 'thejson' 'theimgfolder'
- it generates the static file in the website output folder
THE IMAGES DONT WORK!!!
okay looking at the source i saw the path to the images is wrong in all of them but its an easy fix.
- wheen the static site files were created it created an extra folder you dont want its 'readinglistarchives'
- once you get rid of that your golden
No comments:
Post a Comment