https://github.com/mscbuild/web_blocker
๐ค Python Website Blocker. Software that prevents annoying websites from appearing.
https://github.com/mscbuild/web_blocker
basic block developer developer-tools project python security testing virus website
Last synced: 11 months ago
JSON representation
๐ค Python Website Blocker. Software that prevents annoying websites from appearing.
- Host: GitHub
- URL: https://github.com/mscbuild/web_blocker
- Owner: mscbuild
- License: mit
- Created: 2025-06-12T08:26:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-12T09:25:12.000Z (about 1 year ago)
- Last Synced: 2025-06-12T09:37:37.080Z (about 1 year ago)
- Topics: basic, block, developer, developer-tools, project, python, security, testing, virus, website
- Language: Python
- Homepage:
- Size: 39.1 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ ๏ธ Project: Python Website Blocker








# ๐ What It Does
Blocks specified websites during working hours by editing the system's `hosts` file.
# ๐ Files and Structure
You only need one main Python file:
~~~ruby
website_blocker.py
~~~
# ๐งฐ Requirements
- Python 3.x
- Admin/root privileges (to modify the `hosts` file)
# ๐ง How It Works
- Modifies the hosts file on your system.
- Redirects websites to 127.0.0.1, essentially blocking them.
- Unblocks them after working hours.
# โ๏ธ Location of hosts File
- Windows: `C:\Windows\System32\drivers\etc\hosts`
- Linux/Mac: `/etc/hosts`
# ๐งพ Sample Code
~~~ruby
website_blocker.py
~~~
# โ ๏ธ Note
- Run as Admin/root: Youโll need to run the script with administrative privileges.
- Schedule It: Use Task Scheduler (Windows) or `cron` (Linux/macOS) to run it in the background.
# โ
Possible Upgrades
- GUI using `tkinter` or `PyQt`
- Add/Remove websites dynamically
- Block based on categories (social, entertainment)
- Notifications or logging
# ๐จ Python Website Blocker with GUI (tkinter)
โ
Fe
- GUI to
- S
- View
- Ru
# ๐ File: `website_blocker_gui.py`
# โ๏ธ How to Run
- Run with admin/root permissions.
- Run the script:
~~~ruby
python website_blocker_gui.py
~~~
- Add websites, and click Start Blocking.
# ๐ง Optional Enhancements
- Save/load blocked websites list to file
- Customize working hours in GUI
- Tray icon or minimize-to-tray
Auto-start on system boot
# ๐ ๏ธ Steps to Convert to a macOS App
**Step 1: Install PyInstaller**
First, you'll need to install PyInstaller to
~~~ruby
pip install pyinstaller
~~~
**Step 2: Create**
- Navigate to the directory where y
- Run the following command to create a standalone app (this will generate a `.app` fi)
~~~ruby
pyinstaller --onefile --windowed website_blocker_gui.py
~~~
- `--onefile`: Pa
- `--windowed`: Preve
This will generate a `dist` folder cwebsite_blocker_.
***Step 3:***
Once PyInstaller finishes, you should see a .app file in the `dist directoryWebsite GUI jus
***Step 4:***
- If yo
- Creat (if you)
- Open Keychain A andDevelo certi
- Use t
~~~ruby
codesign --sign "Developer ID Application: Your Name (Team ID)" path/to/website_blocker_gui.app
~~~
***Step 5:***
If you want to create a downloadable disk image for distribution, you can package the `.app` file `.dmg` file for
- Install `create-dmg`:
~~~ruby
npm install -g create-dmg
~~~
- Run th
~~~bash
create-dmg "dist/website_blocker_gui.app" "dist/website_blocker_gui.dmg"
~~~
This will generate a `.dmg` file, w
# ๐ Y
Now you have a standalone macO that runs yo
# Notifications
> [!NOTE]
> If you use an app-level blocker, make sure it is protected from abuse..
> [!TIP]
> Blocking websites may not always be effective, and users can bypass blocking. It is just one tool for increasing security and control.
> [!IMPORTANT]
> A real application would require more complex mechanisms for processing requests, filtering, storing a list of blocked sites, etc.
> [!WARNING]
> Warning: Site blockers may conflict with other network and browser settings. Please note potential issues and possible alternative solutions.
# ๐ License
MIT License ยฉ 2025