From: Svenne Krap Date: Sat, 30 Jun 2012 18:59:22 +0000 (+0200) Subject: updated script to take all of the history for all tabs for all windows X-Git-Url: https://git.svenne.dk/?p=public%2Fmisc-sysadmin.git;a=commitdiff_plain;h=b3637764a8b14d07508343b7fd1143150f822c7a updated script to take all of the history for all tabs for all windows --- diff --git a/save_firefox_urls.py b/save_firefox_urls.py index 82dcd1c..c28857e 100755 --- a/save_firefox_urls.py +++ b/save_firefox_urls.py @@ -37,22 +37,37 @@ if thefile == None: print("cant find profile") sys.exit() -data = open(thefile + "/sessionstore.js",'r').read() +thefile = basedir + "/" + thefile + "/sessionstore.js" +print ("Using " + thefile) +data = open(thefile,'r').read() j = json.loads(data) fields = ["title","url"] -tabs = len(j['windows'][0]["tabs"]) +windows = len(j['windows']) outfp = open(outfile,"w") -for t in range(tabs): - try: - title = j['windows'][0]["tabs"][t]["entries"][0]["title"] - except: - title = ""; - try: - url = j['windows'][0]["tabs"][t]["entries"][0]["url"] - except: - continue - outfp.write( str(t) + " " + title + " " + url + "\n") +for w in range(windows): + print("Looking at window " + str(w)) + tabs = len(j['windows'][w]["tabs"]) + print (" Found " + str(tabs) + " tabs") + for t in range(tabs): + print(" Looking at tab " + str(w)) + entries = len(j['windows'][w]["tabs"][t]["entries"]) + print(" History depth: " + str(entries)) + + for e in range(entries): + try: + title = j['windows'][w]["tabs"][t]["entries"][e]["title"] + except: + title = ""; + try: + url = j['windows'][w]["tabs"][t]["entries"][e]["url"] + except: + continue + print (" Found:") + print (" Entry: " + str(e)) + print (" Title: " + title) + print (" Url : " + url) + outfp.write( str(w) + " " + str(t) + " " + str(e) + " " + title + " " + url + "\n") outfp.close() print ("Saved as " + outfile)