Irrespective of the programming language used, you could add entries to the
hosts file[
^] such that a specific URL is blocked (by make it point to the local host).
So, it would basically be a file write operation, but your program will require administrative privileges to run.