Created
December 29, 2023 22:41
-
-
Save VimalMollyn/f6ac4811c53543d9bf8b8ee66e5c7179 to your computer and use it in GitHub Desktop.
Read through Chrome history with python and pandas
This file contains hidden or 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
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