Created
November 4, 2015 22:50
-
-
Save n8henrie/f4cfb15a78e32dc3eee8 to your computer and use it in GitHub Desktop.
Export your Chrome search engines to JSON.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""chrome_se_export.py | |
Export your Chrome search engines to JSON. | |
""" | |
import os.path | |
import sqlite3 | |
import re | |
import json | |
import click | |
@click.command() | |
@click.option( | |
'--path', | |
default='~/Library/Application Support/Google/Chrome/Default/Web Data', | |
help="Path to Chrome's 'Web Data' Folder") | |
@click.option( | |
'--outfile', | |
default='se_from_chrome.json', | |
help="Output file") | |
def export(path, outfile): | |
path = os.path.expanduser(path) | |
conn = sqlite3.connect(path) | |
with conn: | |
try: | |
keywords = conn.execute('''select * from keywords''') | |
except sqlite3.OperationalError: | |
print("Is Chrome running? Must be closed to work.\n") | |
raise | |
search_engines = [{'name': kw[1], 'keyword': kw[2], 'url': kw[4]} | |
for kw in keywords if re.search(r'{searchTerms}', kw[4])] | |
output = json.dumps(search_engines, sort_keys=True, indent=4, | |
separators=(',', ': ')) | |
with open(outfile, 'w') as w: | |
w.write(output) | |
if __name__ == "__main__": | |
export() | |
@procopaeus still seems to work.
$ python3 -m venv .venv
$ ./.venv/bin/python -m pip install click
$ ./.venv/bin/python chrome_se_export.py --path ~/Library/Application\ Support/Google/Chrome/Default/Web\ Data --outfile foo.txt
$ cat foo.txt
This seems to work OK for Windows Chrome from WSL with something like python3 ~/v/chrome_se_export.py --path "/mnt/c/Users/$MyUser/AppData/Local/Google/Chrome/User Data/$MyProfile/Web Data"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this still work today? I tried tweaking what I could, but I'm a newbie...