Export Chrome search engines to use in firefox.
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Grab the search engines from Chrome and try to put them into a format that | |
Firefox can import so you have the same keywords to use there. | |
Only works on Linux right now. And with the Default profile. So yeah... | |
""" | |
import sqlite3 | |
import os | |
# change this for your OS | |
DB_PATH = os.path.expanduser("~/.config/google-chrome/Default/Web Data") | |
def main(): | |
s = sqlite3.connect(database=DB_PATH) | |
keywords = s.execute('select keyword, short_name, url, date_created from \ | |
keywords where url not like "%gooogle:baseURL%"') | |
output = open('search_engines.html', 'w') | |
output.write("""<!DOCTYPE NETSCAPE-Bookmark-file-1> | |
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> | |
<TITLE>Bookmarks</TITLE> | |
<DL><p> | |
<DT> | |
<DT><H3>Search engines from Chrome</H3> | |
<DD>Search engines imported from chrome. | |
<DL><p>""") | |
for row in keywords: | |
url = row[2].replace('{searchTerms}', '%s') | |
TMPL = """<DT><A HREF="{url}" ADD_DATE="{created}" | |
LAST_MODIFIED="{created}" \ | |
SHORTCUTURL="{keyword}">{short_name}</A>\n""" | |
output.write(TMPL.format(url=url, created=row[3], | |
keyword=row[0], short_name=row[1])) | |
output.write("</DL>") | |
output.close() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment