Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Website Blocker Using Python(2)

Uploaded by

rajunetha2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Website Blocker Using Python(2)

Uploaded by

rajunetha2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

ANNAMACHARYA INSTITUTE OF TECHNOLOGY AND SCIENCES

Piglipur (V), Batasingaram (P), Hayathnagar (M), R.R.Dist., HYDERABAD

Department of Computer Science and Engineering

Technical Seminar on :

Developing a Python-Based Website Blocker


Under Guidance by:
A.Deepika mam M.Tech
Asst.professor

PRESENTED BY:
G.RAJU(21T81A0552)
AGENDA
Introduction
Literature survey
Existing System with problem statement
Proposed system with objective
System Architecture
Output screens
Implementation (code)
Conclusion
References
INTRODUCTION

A Website blocker using python can be used to block certain


websites during work hours to improve productivity.

Website blocker is a software program that is used to block any


website on the internet which we are distracting.
LITERATURE SURVEY
Third-party Applications: Freedom,
Cold Turkey, and Stay Focused.
Built-in Browser Extensions.
Studies show that blocking distractions
can improve productivity by up to 40%
in focused tasks.
EXISTING SYSTEM WITH PROBLEM
STATEMENT
OpenDNS: Provides DNS-based blocking.

 Tools like Net Nanny or Kaspersky.

Drawbacks: Expensive, lack of time-based control .

 Many users find these tools restrictive or not customizable


enough for their specific needs.
Problem Statement
There is a need for an open-source, customizable, and easy-to-use website
blocking tool that can create to individual requirements without involving
complex installations or high costs.
Disadvantages

Slow speed

Heavy memory usage

 More Expensive

Lack of time-based control


PROPOSED SYSTEM WITH OBJECTIVE

This application can be used to block


the websites so that the user can not
open them during the specific period.

So that user can access those


websites during the free time only.
ADVANTAGES
Specific websites to block

Time-bound control

Lightweight, user-friendly

Open-source and customizable.


SYSTEM ARCHITECTURE

Input Module

Processing Module

Host File Update

Scheduler

Output Module
OUTPUT SCREENS
IMPLEMENTATION (CODE)
import os
import platform
import time

# Path to the hosts file based on the operating system


hosts_path = "/etc/hosts" if platform.system() != "Windows" else r"C:\\Windows\\System32\\drivers\\etc\\hosts"
redirect_ip = "127.0.0.1"
blocked_websites = []

# Function to block websites


def block_websites(websites, start_time, end_time):
print("Blocking websites...")
while True:
current_time = time.localtime()
if start_time <= current_time.tm_hour < end_time:
with open(hosts_path, 'r+') as file:
content = file.read()
for website in websites:
if website not in content:
file.write(f"{redirect_ip} {website}\n")
else:
with open(hosts_path, 'r+') as file:
lines = file.readlines()
file.seek(0)
for line in lines:
if not any(website in line for website in websites):
file.write(line)
file.truncate()
print("Websites unblocked.")
break

print("Websites are currently blocked. Sleeping for 60 seconds...")


time.sleep(60)
# Main program
def main():
global blocked_websites
try:
print("--- Website Blocker ---")
websites = input("Enter websites to block, separated by commas: ").split(",")
blocked_websites = [website.strip() for website in websites]

start_time = int(input("Enter start time (24-hour format, e.g., 9 for 9 AM): "))
end_time = int(input("Enter end time (24-hour format, e.g., 17 for 5 PM): "))

block_websites(blocked_websites, start_time, end_time)

except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()
Example:

Website Blocker

Enter website:
[www.facebook.com]

Start time:9:00 am
End time:5:00 pm

[start] [stop]
CONCLUSION

Python Website Blocker offers an efficient and free solution for web
filtering.
We can go away from the distracting websites.
REFERENCES
• Python Documentation: https://www.python.org/doc/

• System File Paths: Windows and Linux Official Documentation

• Time Library Documentation: https://docs.python.org/3/library/time.html.


Thank You

You might also like