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:
dldenotes a list of bookmark items and folders.dtdenotes either a bookmark item or folder:- If it's a bookmark item,
dthas a singleatag child, which gives the bookmark attributes (href, title, etc.). - If it's a bookmark folder,
dthas 3 children:- A
h3tag containing the folder attributes (title, etc.) - A
dltag containing the folder's contents. - A useless
pchild 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
|