在某些条件下阻止网站
我想创建一个简单的程序,在某些条件下(例如,如果第二天要交作业,晚上 7:00 之后)将阻止用户的某些网站。这只是我自己/自律的编程练习,因此它不必支持密码或任何其他安全性。它只需要非常基本。您建议在这个项目中使用什么语言?我该如何去做?我是一名初学者 Java 程序员,并且了解 C++ 的基础知识,尽管我认为这是一个脚本语言类型的项目。有什么建议吗?
I'd like to create a simple program that will block certain websites for the user under certain conditions (e.g. after 7:00pm if homework is due the next day). This would be just a programming exercise for myself/for self discipline, so it would not have to support passwords or any other security. It need only be very basic. What language would you recommend using for this project, and how might I go about doing it? I'm a beginner Java programmer, and know the very basics of C++, although I think this is a scripting language type project. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
执行此操作的唯一可靠方法是构建一个代理 HTTP 服务器来实现您想要强制执行的网站访问策略。这通常需要在单独的计算机上运行,因为用户无法禁用它。然后,您配置网络防火墙,以便用户的计算机无法直接访问远程 HTTP 服务器,而必须使用代理服务器。
这可能不是一个编程问题。相反,您需要找到一些可以实施您想要的策略的现有代理服务器,安装它、配置它并配置您的防火墙和浏览器 Web 访问。
编辑:如果您这样做是为了对自己施加纪律,最简单的方法是编写一个 代理自动配置文件,将您发送至诸如此之类的页面。
The only bomb-proof way you do this is to build a proxy HTTP server that implements the website access policies that you want to enforce. This typically needs to run on a separate machine for that the user cannot disable it. Then you configure your network firewalls so that the user's machine cannot access remote HTTP servers directly, but has to use your proxy server.
This is probably not a programming problem. Rather you need to find some existing proxy server that can implement the kinds of policies that you want, install it, configure it and configure your firewall and browser web-access.
EDIT : if you are doing this to impose discipline on yourself, the easy way would be to write an Proxy Auto-config file that sends you to some page like this.
没有这么简单的程序。您正在编写一个程序,浏览器是另一个程序。您无法在浏览器之外编写程序来访问并执行此类操作。您可以编写插件:一个用于 IE,一个用于 FireFox,一个用于 Opera。然后你必须说服你的用户/受害者安装它/他们。
There is no such simple program. You are writing one program, the browser is another. You can't write a program outside the browser that reaches in and does this sort of thing. You can write plugins: one for IE, one for FireFox, one for Opera. And then you have to convince your User/Victim to install it/them.
如果您使用的是 Windows,则可以创建两个
c:\windows\system32\drivers\etc\hosts
副本。制作一份原始副本,然后在第二份副本中添加您想要限制的站点的条目:接下来,创建两个计划任务。一种用原始文件替换主机,另一种用受限制的文件替换主机。
If you are on Windows, you can create two copied of
c:\windows\system32\drivers\etc\hosts
. Make one copy your original, and to the second one, add entries the site you'd like to restrict:Next, create two scheduled tasks. One to replace hosts with the original file and the other one to replace hosts with your restricted file.