Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Export Chrome/Chromium history directly from the browser's database. Based on , but works with more recent versions of the browser.
#!/usr/bin/env python
import os
import sys
import datetime
import sqlite3
SQL_VISITS = 'select v.visit_time, u.url from visits v inner join urls u on (v.url = order by v.visit_time'
def date_from_webkit(webkit_timestamp):
epoch_start = datetime.datetime(1601, 1, 1)
delta = datetime.timedelta(microseconds=int(webkit_timestamp))
return epoch_start + delta
def main(db_filename):
assert os.path.exists(db_filename)
c = sqlite3.connect(db_filename)
visits = list((date_from_webkit(row[0]), row[1]) for row in c.execute(SQL_VISITS))
for v in visits:
print('"{}", "{}"'.format(*v))
return 0
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Usage: {} <path-to-chrome-history-file>".format(sys.argv[0]))
print(" for Chromium 38 on MacOS: ~/Library/Application\ Support/Chromium/Default/History ")
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.