python
Dashboard
My Repos
Compilers
Python Online
Node JS Online
Golang Online
codepy
Login
My Repos
Sign Out
Online Python Interpreter
Stop
Run
from datetime import datetime host_path='' redirect="" website_list=["www.facebook.com","www.instragram.com"] start_date=datetime(2020,12,13) end_date=datetime(2020,12,14) today_date=datetime(datetime.now().year,datetime.now().month,datetime.now().day) while true: if start_date<=today_date<end_date: with open(host_path,"r+") as file: content=file.read() for site in website_list: if site in content: pass else: file.write(redirect+" "+site+"\n") print("ALL SITE ARE BLOCKED") break else: #means= end_date < today_date with open(host_path,"r+") as file: content=file.readline() file.seek(0) for line in content: if not any(site in line for site in website_list): file.write(line) file.truncate() print("all site unblocked") break
Share this code with others
Public
Clear
My Repos
Repo
Lang
Login
Register
Login
Create a free account. No Credit card info required.
I agree with the Codepy
Term of Service
Sign Up