Reading Chrome Bookmarks using Python Module chrome_bookmarks


Chrome Browser Bookmark file is in JSON format whereas history file is a database format. One can read the data file using SQLite(DB Browser) to get the URL and downloads data.

In this post I am using chrome-bookmarks module to read the bookmarks and print the URL along with it Name and Folder Information.

Install chrome-bookmarks module using pip

pip install chrome-bookmarks

Now you can read the URL from Python as below.

import chrome_bookmarks
for url in chrome_bookmarks.urls:
    print(url.url)

We Can also print the URL Description/Name as below.

import chrome_bookmarks
for url in chrome_bookmarks.urls:
    print(url.url, url.name)
import chrome_bookmarks

for folder in chrome_bookmarks.folders:
    print(folder.name)
    print(folder.folders)

It is also possible to read the JSON without using the above module.

import json
file ="C:\\Users\\Dell\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Bookmarks"
with open(file, "r", encoding='utf-8') as bookmarks:
    bookmark_data = json.load(bookmarks)
    print(json.dumps(bookmark_data, indent=1))

{
 "checksum": "7b7d115080ddda0dcab6b428f64aa3a5",
 "roots": {
  "bookmark_bar": {
   "children": [
    {
     "date_added": "13326789370504643",
     "date_last_used": "0",
     "guid": "5c3e2329-1d0c-4a9d-b85e-426d6fd31301",
     "id": "62",
     "meta_info": {
      "power_bookmark_meta": ""
     },
     "name": "Oracle | Cloud Applications and Cloud Platform",
     "type": "url",
     "url": "https://www.oracle.com/"
    },
    {
     "date_added": "13326789428536219",
     "date_last_used": "0",
     "guid": "0a972887-7f34-41b3-bf59-1f2f2f521a0e",
     "id": "63",
     "meta_info": {
      "power_bookmark_meta": ""
     },
     "name": "Oracle Database Features",
     "type": "url",
     "url": "https://apex.oracle.com/database-features/"
    },
    {
     "date_added": "13326789439984046",
     "date_last_used": "0",
     "guid": "25e1d231-a825-46fd-a8a9-829bf07dc5bf",
     "id": "64",
     "meta_info": {
      "power_bookmark_meta": ""
     },
     "name": "Cloud Sign In",
     "type": "url",
     "url": "https://www.oracle.com/cloud/sign-in.html?redirect_uri=https%3A%2F%2Fcloud.oracle.com%2F"
    },
    {
     "date_added": "13326789456087992",
     "date_last_used": "0",
     "guid": "a0e39859-9596-47be-bc61-d6099f152fb1",
     "id": "65",
     "meta_info": {
      "power_bookmark_meta": ""
     },
     "name": "Oracle Blogs",
     "type": "url",
     "url": "https://blogs.oracle.com/"
    },
    {
     "children": [
      {
       "date_added": "13326789491584887",
       "date_last_used": "0",
       "guid": "b6f90dec-e303-4a2b-bb53-a7357c8d694f",
       "id": "67",
       "meta_info": {
        "power_bookmark_meta": ""
       },
       "name": "Oracle | Cloud Applications and Cloud Platform",
       "type": "url",
       "url": "https://www.oracle.com/"
      },
      {
       "date_added": "13326789491585797",
       "date_last_used": "0",
       "guid": "ffeea96a-87d7-4053-b674-7ac9cfb50a13",
       "id": "68",
       "meta_info": {
        "power_bookmark_meta": ""
       },
       "name": "Oracle Database Features",
       "type": "url",
       "url": "https://apex.oracle.com/database-features/"
      },
      {
       "children": [
        {
         "date_added": "13326789491586570",
         "date_last_used": "0",
         "guid": "851ce296-3918-47ab-981a-21fcab632edc",
         "id": "70",
         "meta_info": {
          "power_bookmark_meta": ""
         },
         "name": "Oracle Blogs",
         "type": "url",
         "url": "https://blogs.oracle.com/"
        },
        {
         "date_added": "13326789491586243",
         "date_last_used": "0",
         "guid": "5b21937d-66d9-4eea-9491-7d7c2e22152b",
         "id": "69",
         "meta_info": {
          "power_bookmark_meta": ""
         },
         "name": "Cloud Sign In",
         "type": "url",
         "url": "https://www.oracle.com/cloud/sign-in.html?redirect_uri=https%3A%2F%2Fcloud.oracle.com%2F"
        }
       ],
       "date_added": "13326789519632624",
       "date_last_used": "0",
       "date_modified": "13326789527363048",
       "guid": "9b0bbece-a9fd-4678-a846-896b7a2a54ec",
       "id": "71",
       "name": "Oracle_Child",
       "type": "folder"
      }
     ],
     "date_added": "13326789485096843",
     "date_last_used": "0",
     "date_modified": "13326789519632800",
     "guid": "ea6663fa-05df-4751-b25b-125561aed88d",
     "id": "66",
     "name": "Oracle",
     "type": "folder"
    }
   ],
   "date_added": "13326774450786953",
   "date_last_used": "0",
   "date_modified": "13326789491586570",
   "guid": "0bc5d13f-2cba-5d74-951f-3f233fe6c908",
   "id": "1",
   "name": "Bookmarks bar",
   "type": "folder"
  },
  "other": {
   "children": [],
   "date_added": "13326774450786955",
   "date_last_used": "0",
   "date_modified": "0",
   "guid": "82b081ec-3dd3-529c-8475-ab6c344590dd",
   "id": "2",
   "name": "Other bookmarks",
   "type": "folder"
  },
  "synced": {
   "children": [],
   "date_added": "13326774450786957",
   "date_last_used": "0",
   "date_modified": "0",
   "guid": "4cf2e351-0e85-532b-bb37-df045d8f8d0f",
   "id": "3",
   "name": "Mobile bookmarks",
   "type": "folder"
  }
 },
 "version": 1
}

Hope you like it. ! Happy learning.

Published by

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.