id | aliases | tags |
---|---|---|
SqlitePythonCountChrome |
# -*- coding: utf-8 -*-
import datetime
import sqlite3
db = '/home/lizhe/.config/google-chrome/Profile 1/History'
db = '/home/lizhe/History'
conn = sqlite3.connect(db)
c = conn.cursor()
c.execute('select * from urls')
result = c.fetchall()
# count urls visited today and yesterday
today = datetime.datetime.now().strftime('%Y-%m-%d')
yesterday = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
today_count = 0
yesterday_count = 0
for row in result:
url = row[1]
time_str = row[5]
time_str = datetime.datetime(1601, 1, 1) + datetime.timedelta(microseconds=int(time_str))
time_str = time_str.strftime('%Y-%m-%d')
if time_str == today:
today_count += 1
if time_str == yesterday:
yesterday_count += 1
print('today: %d, yesterday: %d' % (today_count, yesterday_count))