Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Export Firefox (and other Mozilla-based browser) bookmarks without Firefox

I wrote a library in Python3 to export the bookmarks from Mozilla-based browsers. That means, for browsers like Waterfox, Palemoon, LibreWolf, Firefox, and others, you can use some python commands to extract bookmarks into an html file. Check out the source at gitlab. The basic usage includes finding the available profile directories.

$ python3
>>> import mbbmlib
>>> mbblib.find_available_places() # takes an optional string, which is the directory to search under. Default is your $HOME.
['/home/bgstack15/.config/newmoon','/home/bgstack15/.mozilla/firefox/l1834dn1.default']
>>> mbblib.export_bookmarks_to_html("/home/bgstack15/.mozilla/firefox/l1834dn1.default","/mnt/public/bookmarks-desktop5.html",fetch_icons=True,debuglev=8)

It will output an html file with unordered lists of the contents, in order, of your bookmarks. I did notice it does not handle separators, so if you really want separators, please submit a pull request! I know Firefox and similar browsers can export their bookmarks within the browser itself. I didn't want to run the browser to access these values, as well as I wanted to force the icons to be included which is not a function that Firefox does. Screenshot
of a few bookmarks from an html file generated with
mbbmlib

Trivia

Firefox does not store its bookmarks' icons in favicons.sqlite. I had to use the Google favicon api http://www.google.com/s2/favicons?sz={0}&domain={1}".format(iconsize,domain) to download favicons. It was that, or write a lot of logic to try all the places a favicon could be, for a given domain. And yes, I know a favicon can be different for pages underneath a domain. I was taking the easy route. Feel free to fix this one too with a patch! I really struggled with the blasted encoding of things as you can see from the screenshots. If you want to submit a patch for that, please save me from myself!

Comments