Created
April 10, 2014 15:10
-
-
Save harmonbc/10392318 to your computer and use it in GitHub Desktop.
Turn Firefox's History into a CSV file.
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
""" | |
@author: Brandon Harmon | |
@date : 9 April, 2014 | |
@description: | |
Pass this program the location of the places.sqlite file for firefox | |
(for me it is ~/.mozilla/firefox/mwad0hks.default/places.sqlite) | |
It will output a csv file where you designate in the 2nd param | |
""" | |
import sqlite3 as lite | |
import sys | |
import csv | |
from urlparse import urlparse | |
def main(): | |
if len(sys.argv) < 1: | |
print "ffhisttocsv.py <loc of places.sqlite> <out file>" | |
return | |
con = lite.connect(sys.argv[1]) | |
cur = con.cursor() | |
cur.execute('SELECT url FROM moz_places') | |
rows = cur.fetchall() | |
urls = [] | |
for row in rows: | |
parsed_uri = urlparse(row[0]) | |
domain = '{uri.scheme}://{uri.netloc}/'.format(uri=parsed_uri) | |
urls.append(domain) | |
urls = list(set(urls)) | |
with open(sys.argv[2],'w') as csv_file: | |
csv_writer = csv.writer(csv_file, delimiter=',', quoting=csv.QUOTE_NONE) | |
csv_writer.writerow(urls) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to print the visit date aswell and counter aswell?