Skip to content

Instantly share code, notes, and snippets.

@rectalogic
Last active July 9, 2016 16:50
Show Gist options
  • Save rectalogic/3ae2c06016e172f52e857bfe0e95dce3 to your computer and use it in GitHub Desktop.
Save rectalogic/3ae2c06016e172f52e857bfe0e95dce3 to your computer and use it in GitHub Desktop.
Convert Feedly "Saved For Later" to Netscape bookmarks format for import into pinboard.in

First, go to https://feedly.com/i/saved in Chrome and scroll down until all items have loaded. Then open Chrome Dev Tools and navigate to the //*[@id="section0_column0"] nested div. Right click and Copy > Copy element. Paste this into a file feedly-saved.html Run feedly_to_pinboard.py to generate feedly-bookmarks.html - import this into Pinboard.

import datetime
import cgi
import re
from bs4 import BeautifulSoup
RE = re.compile("[ ,]")
with open("feedly-saved.html") as f:
soup = BeautifulSoup(f, 'html.parser')
items = []
for div in soup.div("div", recursive=False):
title = div["data-title"]
url = div["data-alternate-link"]
date = datetime.datetime.strptime(div.span["title"].split(" -- ")[0], "published:%a, %d %b %Y %H:%M:%S %Z")
source = div.find(name="span", class_="sourceTitle").a.text
items.append(u"""<DT><A HREF="{url}" ADD_DATE="{date}" PRIVATE="0" TAGS="{tags},feedly">{title}</A>""".format(
url=url, date=int(date.strftime("%s")), tags=cgi.escape(RE.sub("_", source)), title=cgi.escape(title)))
bookmarks = u"""<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
{}
</DL><p>
""".format(u"\n".join(items))
with open("feedly-bookmarks.html", "w") as f:
f.write(bookmarks.encode("utf-8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment