Skip to content

Instantly share code, notes, and snippets.

@MimiOnuoha
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MimiOnuoha/f50c8c71a2569b2e1b8d to your computer and use it in GitHub Desktop.
Save MimiOnuoha/f50c8c71a2569b2e1b8d to your computer and use it in GitHub Desktop.
Access Firefox/Chrome search keywords
## Super simple Python code for querying a Chrome or Firefox database to access keywords and put them into a CSV.
## You'll need to make sure that your browser history file is already in the working directory, find them at below paths for OSX:
## Chrome: /Users/$USER/Library/Application Support/Google/Chrome/Default/Preferences
## Firefox: /Users/$USER/Library/Application Support/Firefox/Profiles/$PROFILE.default/places.sqlite
import dataset, csv
def grab_keywords(filename):
db = dataset.connect(filename)
result = db['keyword_search_terms'].all()
## For Firefox, uncomment the line below instead:
## result = db['moz_keywords.keyword'].all()
dataset.freeze(result, format = 'csv', filename = 'keywords.csv')
grab_keywords('sqlite:///History') #change to 'sqlite:///places.sqlite' for Firefox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment