Python Website Blocker-The Beginner’s Project

Website Blocker


Python is one of the broadly mainstream programming dialects right now. It's has a promising future. It works on various platforms like Windows, Mac, Linux, Raspberry Pi, etc. It has a huge standard library that has a rich set of modules and functions so you do not have to write your code for every single thing. 

perhaps the most ideal approach to get profound information on any 

programming language and it likewise illuminates our critical thinking aptitudes. 

Project-based learning is the most ideal approach to get profound information on any programming language and it likewise illuminates our critical thinking aptitudes. So, if you are a Python beginner, you can work on a various project which you can add in your git repository as well as in your CV. 

Python website blocker


Python website blocker is a beginner’s project. It is used to block certain websites for a designated amount of time. In this, you can impede any site that troubles you during your working hours or study hours. Website blocker helps you to stay concentrated and improve productivity. Rather than utilizing an outsider framework assemble yours, become focused by removing distractions from your life in just a few clicks!


Requirements

To make a website blocker one should know the Datetime and time python module and a little bit regarding the host file.


HOST FILE

The hosts’ file ("hosts.txt") is a plain-text file that contains a list of hostnames and their corresponding IP addresses. To block access to a specific website on the computer, we need to configure the hosts’ file.

Location of the hosts’ file

The location of the hosts’ file varies from the operating system to operating system

Windows: C:\Windows\System32\drivers\etc

mac and Linux: /etc/hosts

Image of host file:

Website Blocker Using Python - GeeksforGeeks

In the host file, we will add the list of the website URLs we want to block. We can do it manually or by using python programming.

Flowchart


ALGORITHM

  1. Import the libraries DateTime, os, sys.
  2. Create a variable host_file in which the host file address is stored.
  3. Create a list of the websites to be blocked named the list as a website.\
  4. Initialize start, end, and current date in different variables to check the condition.
  5. Then the condition is checked if the start_date<=today_date<end_date.
  6. If yes then the host file is opened in reading and write mode.
  7. And websites to be blocked in the write-in host file.
  8. Then the file is truncated.

Now your python website blocker is ready. Start implementing it in your day-to-day life and keeping on exploring other python libraries.

References:

https://www.javatpoint.com/python-website-blocker



Shreya Goel (2019-2023)

Computer Science Department
KIET Group of Institutions

Comments

Popular posts from this blog

QUANTUM STORAGE & MEMORY

Biofuel generation with the help of Bioinformatics

PHISHING ATTACKS IN INDIA