Skip to content

Instantly share code, notes, and snippets.

@kevit
Created February 19, 2013 14:58
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save kevit/4986610 to your computer and use it in GitHub Desktop.
Save kevit/4986610 to your computer and use it in GitHub Desktop.
Safari Reading list to Pocket import script
#!/bin/sh
#http://getpocket.com/import/instapaper
set -x
cat >> /tmp/import.html << "EOF"
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Instapaper: Export</title>
</head>
<body>
<h1>Unread</h1>
<ol>
<li><a href="
EOF
for i in `/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}://.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>//g'`; do
echo $i >> /tmp/import.html
echo "\">" >> /tmp/import.html
echo $i >> /tmp/import.html
# curl -L $i |grep "<title>" |sed -e :a -e 's/<[^>]*>//g;/</N;//ba' >> /tmp/import.html
echo "</a></li><li><a href=\"" >> /tmp/import.html
done
cat >> /tmp/import.html << "EOF"
</a></li>
</ol>
<h1>Archive</h1>
<ol>
<li><a href="http://">http://</a></li>
</ol>
</body>
</html>
EOF
@malikz33
Copy link

Any help/tip on how to implement this? Sorry, I know it's a noob question.

@erineland
Copy link

This creates a html file and places it in a folder called tmp in the root of your computer. This file contains all of the links of the reading list, actually rather buggily, all of your safari bookmarks.

@weiweiwei33
Copy link

Hello! Does Pocket automatically import articles from the html file in the tmp folder created by this script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment