Skip to main content

Install

$ pip install zbookmarks

Usage

A simple python package for loading / dumping Chrome HTML bookmarks. Born out of necessity to fix my own bookmarks.

import zbookmarks

# Load
with open("chrome_bookmarks.html", "r") as f:
    bookmarks = zbookmarks.load_chrome(f.read())

# Print
print(bookmarks)

# Dump
with open("output.html", "w") as f:
    zbookmarks.dump_chrome(bookmarks, f)

How it works

I made this package by examining my own Chrome bookmark files and extrapolating. The general rules are:

  • dl denotes a list of bookmark items and folders.
  • dt denotes either a bookmark item or folder:
    • If it's a bookmark item, dt has a single a tag child, which gives the bookmark attributes (href, title, etc.).
    • If it's a bookmark folder, dt has 3 children:
      • A h3 tag containing the folder attributes (title, etc.)
      • A dl tag containing the folder's contents.
      • A useless p child tag.

I found it easier to come up with these rules after visualizing the DOM tree of a Chrome bookmarks file:

Visualize DOM tree of bookmarks file

You can try it out on your own bookmark file by running:

# You need to install graphviz (dot) in order to run the script
$ sudo apt-get install -y graphviz
$ poetry install
$ python3 scripts/visualize_dom.py <my_bookmarks_file.html>

Metadata

Release files for zbookmarks 1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zbookmarks 1.3
File Size Uploaded
zbookmarks-1.3.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zbookmarks 1.3
File Interpreter ABI Platform
zbookmarks-1.3-py3-none-any.whl Python 3 none any Details

Total release size: 14.2 kB

Release files / zbookmarks-1.3.tar.gz

Download URL zbookmarks-1.3.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ed7137be7c26f71c9bb514a9ef97ecc39ae3561b9d3ce8795d70353b651e5521
BLAKE2b-256 checksum
How to use checksums
7305faebc672fc8e0503e8a73e7021629b25bc12c2cd75d9102738da263ec1fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.5 CPython/3.8.5 Linux/4.19.128-microsoft-standard

Release files / zbookmarks-1.3-py3-none-any.whl

Download URL zbookmarks-1.3-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b16decb4b4c44201d5d89e21135850ddd468aa5642679ff1c6c9fa5984f9ccc
BLAKE2b-256 checksum
How to use checksums
5a6843eb26b9b72e7eccd724a66007c96e7251f0245038a2c953877d0bd5c7b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.5 CPython/3.8.5 Linux/4.19.128-microsoft-standard

Release history Release notifications | RSS feed

This release

1.3 This release

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page