使用Python中的Internet Explorer,Opera,Chrome,Firefox和Safari监视访问的网站 [英] Monitor web sites visited using Internet Explorer, Opera, Chrome, Firefox and Safari in Python

查看:164
本文介绍了使用Python中的Internet Explorer,Opera,Chrome,Firefox和Safari监视访问的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一个工作项目工作,似乎遇到了一个小问题.该项目与Web Nanny相似,但品牌属于我客户的公司.它将具有诸如通过URL,关键字和Web活动日志阻止网站等功能.我还需要它能够暂停"下载,直到输入了可接受的用户名和密码.

I am working on a project for work and have seemed to run into a small problem. The project is a similar program to Web Nanny, but branded to my client's company. It will have features such as website blocking by URL, keyword and web activity logs. I would also need it to be able to "pause" downloads until an acceptable username and password is entered.

我找到了一个脚本来监视在Internet Explorer中访问的URL(如下所示),但它似乎使浏览器的运行速度大大降低.对于如何在其他浏览器中实现此功能,我没有找到任何支持或想法.

I found a script to monitor the URL visited in Internet Explorer (shown below), but it seems to slow the browser down considerably. I have not found any support or ideas onhow to implement this in other browsers.

所以,我的问题是:

1).如何监视其他浏览器活动/访问的URL? 2).除非输入可接受的用户名和密码,否则如何防止下载?

1). How to I monitor other browser activity / visited URLs? 2). How do I prevent downloading unless an acceptable username and password is entered?

from  win32com.client import Dispatch,WithEvents
import time,threading,pythoncom,sys

stopEvent=threading.Event()
class EventSink(object):

    def OnNavigateComplete2(self,*args):
        print "complete",args
        stopEvent.set()


def waitUntilReady(ie):
    if ie.ReadyState!=4:
        while 1:
            print "waiting"
            pythoncom.PumpWaitingMessages()
            stopEvent.wait(.2)
            if stopEvent.isSet() or ie.ReadyState==4:
                stopEvent.clear()
                break;

time.clock()
ie=Dispatch('InternetExplorer.Application',EventSink)
ev=WithEvents(ie,EventSink)
ie.Visible=1
ie.Navigate("http://www.google.com")

waitUntilReady(ie)
print "location",ie.LocationName
ie.Navigate("http://www.aol.com")
waitUntilReady(ie)
print "location",ie.LocationName
print ie.LocationName,time.clock()
print ie.ReadyState

推荐答案

我建议您研究一个不错的Web代理.如果所有机器都在同一网络上,则可以实现透明的缓存Web代理,并在其上放置过滤规则.它们往往是高速的并且可以做很多很酷的事情.

I would recommend looking into a nice web proxy. If the machines are all on the same network you can implement a transparent caching web proxy and put filtering rules on it. They tend to be high speed and can do lots of cool things.

我和乌贼在一起很幸运.这样可以解决您的情况吗?

I have had some luck with Squid. Would this solve your situation?

这篇关于使用Python中的Internet Explorer,Opera,Chrome,Firefox和Safari监视访问的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆