Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Extract bookmarks (from html file) from the browser
@author: jay
from BeautifulSoup import BeautifulSoup
import gdbm
import pickle
import time
def main():
f = open('bookmarks.html','r')
soup = BeautifulSoup(
for d in soup.findAll('dt'):
f ='bookmark','c')
for i in range(len(dt)):
if dt[i].contents[0].has_key('href') and dt[i].contents[0].has_key('add_date'):
uri = dt[i].contents[0]['href']
title = dt[i].contents[0].contents[0]
add_date = time.ctime(int(dt[i].contents[0]['add_date']))
last_modified = time.ctime(int(dt[i].contents[0]['last_modified']))
f[uri] = pickle.dumps((str(title), add_date, last_modified))
if __name__ == '__main__':

This comment has been minimized.

Copy link
Owner Author

commented Jan 27, 2012

Go to Bookmarks in your browser. Open Show All Bookmarks. Import and Backup > Export Bookmark to HTML > Save the file and feed it to the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.