Skip to content

Instantly share code, notes, and snippets.

@woshichuanqilz
Created August 3, 2024 14:28
Show Gist options
  • Save woshichuanqilz/1724dff0694e889ed2dce11958991316 to your computer and use it in GitHub Desktop.
Save woshichuanqilz/1724dff0694e889ed2dce11958991316 to your computer and use it in GitHub Desktop.
Chrome history
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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment