-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebsiteBlocker.pyw
More file actions
27 lines (25 loc) · 982 Bytes
/
websiteBlocker.pyw
File metadata and controls
27 lines (25 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import time
from datetime import datetime as dt
hosts_yolu=r"C:\Windows\System32\drivers\etc\hosts"
yonlendirme="127.0.0.1"
website_liste=["https://www.google.com","google.com","www.google.com"]
baslangicSaati=8
bitisSaati=18
while True:
if dt(dt.now().year,dt.now().month,dt.now().day,baslangicSaati) < dt.now() < dt(dt.now().year,dt.now().month,dt.now().day,bitisSaati):
with open(hosts_yolu,"r+") as dosya:
icerik=dosya.read()
for website in website_liste:
if website in icerik:
pass
else:
dosya.write("\n"+yonlendirme+" "+website)
else:
with open(hosts_yolu,"r+") as dosya:
icerik=dosya.readlines()
dosya.seek(0)
for satir in icerik:
if not any(website in satir for website in website_liste):
dosya.write(satir)
dosya.truncate()
time.sleep(5)