From 7c33c5eb27a909b3e47c2cf93b6ddf47bf99f4a7 Mon Sep 17 00:00:00 2001 From: stef-devs Date: Fri, 29 Jul 2022 12:25:53 +0200 Subject: [PATCH] Print Web History on .csv and search youtube.com --- .gitignore | 5 ++++- main.py | 39 +++++++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index c308ed1..8e4b555 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ executable.py executable.sh siti.dat -history.txt \ No newline at end of file +history.txt +history.csv +test.py +.~lock.history.csv# \ No newline at end of file diff --git a/main.py b/main.py index bc97a7f..962d130 100644 --- a/main.py +++ b/main.py @@ -3,18 +3,32 @@ import tkinter as tk #Libraries for execute command import subprocess #Libraries for read web browser history -from browser_history.browsers import Firefox +from browser_history import get_history +#Libraries for date time +from datetime import datetime +#Libraries for read csv +import csv -#Print all browser history on txt -with open('history.txt', 'w') as f: - fi = Firefox() - outputs = fi.fetch_history() - his = outputs.histories - for line in his: - f.write(str(line)) - f.write('\n') +#Print all browser history on cvs +outputs = get_history() +outputs.save("history.csv") -window = tk.Tk() +#Get current date +now = datetime.now() +date_time_str = now.strftime("%Y-%m-%d %H:%M") +print('DateTime String:', date_time_str) + +#Search Youtube Link on history.csv +how_to_search = 'https://www.youtube.com/' +rows = [] +with open('history.csv', 'rt') as f: + reader = csv.reader(f, delimiter=',') + for line in reader: + if how_to_search in line: + print("Yes!") + +#Create a window +window = tk.Tk() #Resolution program window.geometry("800x500") #Title program @@ -23,6 +37,7 @@ window.title("Poweroffer") window.configure(background="blue") window.grid_columnconfigure(0, weight=1) +#Welcome text scritta = tk.Label(window, text="Welcome!", font=("Helvetica",15)) scritta.grid(row=0, column=0, sticky="N", padx=20, pady=10) @@ -31,11 +46,11 @@ text_input= tk.Entry(textvariable=sito) text_input.grid(row=3, column=0, sticky="WE", padx=10, pady=10) #Button stop procrastinating -second_button= tk.Button(text="Stop procrastinating", command=smetti) +second_button= tk.Button(text="Stop procrastinating") second_button.grid(row=5, column=0, sticky="WE", padx=15, pady=8) #Button for shutdown pc -first_button = tk.Button(text="have a break from the pc", command=spegni) +first_button = tk.Button(text="have a break from the pc") first_button.grid(row=1, column=0, sticky="W", padx=50, pady=50) #Always open window