Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@kliqzero

This comment has been minimized.

Copy link

kliqzero commented Feb 27, 2014

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

@arcadia168

This comment has been minimized.

Copy link

arcadia168 commented Aug 28, 2014

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.

@weiweihsu

This comment has been minimized.

Copy link

weiweihsu commented Oct 7, 2016

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