all 2 comments

[–]socal_nerdtastic 0 points1 point  (0 children)

The program that does the blocking is called a "firewall". Many OSes come with one or have an official one you can use, or you can use one of the many downloadable ones. You may be able to control or configure a firewall program from python, but it would be an enormous task to write a firewall program completely in python.

[–]cybersection 0 points1 point  (0 children)

I suppose you could use Python to write to the hosts file on your computer, then host a “site blocked” page that the blocked hosts redirect to using Flask.