Skip to content

Instantly share code, notes, and snippets.

@VimalMollyn
Created December 29, 2023 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VimalMollyn/f6ac4811c53543d9bf8b8ee66e5c7179 to your computer and use it in GitHub Desktop.
Save VimalMollyn/f6ac4811c53543d9bf8b8ee66e5c7179 to your computer and use it in GitHub Desktop.
Read through Chrome history with python and pandas
import sqlite3
from pathlib import Path
import pandas as pd
from datetime import datetime, timedelta
import IPython
path_to_history = Path("./history")
conn = sqlite3.connect(path_to_history)
df = pd.read_sql_query("SELECT * FROM urls", conn)
# Function to convert WebKit timestamp to datetime
def convert_webkit_timestamp(timestamp):
epoch_start = datetime(1601, 1, 1)
return epoch_start + timedelta(microseconds=timestamp)
# Apply the conversion function to the timestamp column
df['datetime'] = df['last_visit_time'].apply(convert_webkit_timestamp)
df = df.sort_values(by=['datetime']).reset_index(drop=True)
IPython.embed()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment