Skip to content

Instantly share code, notes, and snippets.

@ra312
Last active May 21, 2020 15:32
Show Gist options
  • Save ra312/d28000cd18f704a77f0001d20c9c6e7c to your computer and use it in GitHub Desktop.
Save ra312/d28000cd18f704a77f0001d20c9c6e7c to your computer and use it in GitHub Desktop.
raise my browsing self-awareness
import os
import sqlite3
import operator
from collections import OrderedDict
#path to user's history database (Chrome)
data_path = os.path.expanduser('~')+"/Library/Application Support/Google/Chrome/Default"
files = os.listdir(data_path)
history_db = os.path.join(data_path, 'history')
#querying the db
c = sqlite3.connect(history_db)
cursor = c.cursor()
select_statement = "SELECT urls.url FROM urls, visits WHERE urls.id = visits.url;"
cursor.execute(select_statement)
results = cursor.fetchall() #tuple
urls = [result[0] for result in results]
print('\n'.join(urls))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment