Print Web History on .csv and search youtube.com

This commit is contained in:
stef-devs 2022-07-29 12:25:53 +02:00
parent f9863f8db8
commit 7c33c5eb27
2 changed files with 31 additions and 13 deletions

3
.gitignore vendored
View File

@ -2,3 +2,6 @@ executable.py
executable.sh
siti.dat
history.txt
history.csv
test.py
.~lock.history.csv#

37
main.py
View File

@ -3,17 +3,31 @@ 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")
#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")
@ -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