Load / dump Chrome bookmark files
Project description
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 singlea
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.
- A
- If it's a bookmark item,
I found it easier to come up with these rules after visualizing the DOM tree of a Chrome 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>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
zbookmarks-1.3.tar.gz
(7.0 kB
view details)
Built Distribution
File details
Details for the file zbookmarks-1.3.tar.gz
.
File metadata
- Download URL: zbookmarks-1.3.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.8.5 Linux/4.19.128-microsoft-standard
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed7137be7c26f71c9bb514a9ef97ecc39ae3561b9d3ce8795d70353b651e5521 |
|
MD5 | 66ee70f0ca8bae436c7b1b0ec79d00ed |
|
BLAKE2b-256 | 7305faebc672fc8e0503e8a73e7021629b25bc12c2cd75d9102738da263ec1fd |
File details
Details for the file zbookmarks-1.3-py3-none-any.whl
.
File metadata
- Download URL: zbookmarks-1.3-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.8.5 Linux/4.19.128-microsoft-standard
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b16decb4b4c44201d5d89e21135850ddd468aa5642679ff1c6c9fa5984f9ccc |
|
MD5 | 4c8ca50d7948144e0e126a8f81c306d5 |
|
BLAKE2b-256 | 5a6843eb26b9b72e7eccd724a66007c96e7251f0245038a2c953877d0bd5c7b6 |