In this code with me series, we'll create our own webhistory viewer to extract all the information we can get from Chrome's History file. We the aid of SQLite3 we'll query the needed data to properly execute this program.
CODE:
import csv,sqlite3,os
from datetime import datetime,timedelta
import time
connection = sqlite3.connect("") #creates a connection object that represents the database, then open the History db
connection.text_factory = str #set to use 8bit strings instead of unicode strings in sqlite3
cur = connection.cursor() #creates a cursor object using the cursor method of the connection object class
print "+++Cursor connected+++"
epoch = datetime(1601, 1, 1) #sets an epoch from Jan 1 1601 UTC
query = 'select url, title, visit_count, last_visit_time from urls'
print "+++Query set+++"
execute = cur.execute(query) #set variable to execute query
count = 0
for row in execute: # a loop that would get each query from the database
row = list(row)
url_time = epoch + timedelta(microseconds = row[3])
row[3] = url_time
count += 1
print "Transaction #", count
for r in row:
print r
print "-----------------"
connection.close() #exits DB
Video:
https://youtu.be/gZmp9ScLCJg
コメント