A robust, automated Python script designed to block distracting websites during your specified working hours. By seamlessly modifying the system's hosts file, it redirects unwanted traffic to your local machine—helping you stay focused and productive.
| File Name | Description |
|---|---|
| Website_Blocker.py | Main script that handles time checking and host file updates |
| website_lists.txt | Configuration file containing websites to block |
- ⏰ Time-based website blocking
- 🔄 Automatic unblock outside work hours
- 📝 Simple configuration via text file
- 🖥️ Works at system level (hosts file modification)
Open the website_lists.txt file and add/remove websites:
Example: facebook.com youtube.com instagram.com
Default configuration is for Windows:
C:\Windows\System32\drivers\etc\hosts
For macOS/Linux, update the file path inside the script: /etc/hosts
Because the script modifies the system hosts file, you must run it with elevated permissions.
Steps:
-
Open Command Prompt / PowerShell
-
Right-click → Run as Administrator
-
Navigate to your project folder: cd path\to\your\project\folder
-
Run the script: python Website_Blocker.py
💡 Pro Tip: Use Task Scheduler (Windows) or cron jobs (Linux/macOS) to automate execution in the background.
| Time | Behavior |
|---|---|
| Working Hours | Websites are blocked ❌ |
| Non-working Hours | Access is restored ✅ |
This project helps eliminate distractions by enforcing website restrictions during productive hours—simple, effective, and customizable.

