Python检测警报

时间:2012-07-27 03:21:58

标签: python urllib2

我正在尝试让我的python脚本检测页面上的警告框

import urllib2
url = raw_input("Please enter your url: ")
if urllib2.urlopen(url).read().find("<script>alert('alert');</script>") == 0:
    print "Alert Detected!"

如何让它检测警报?

1 个答案:

答案 0 :(得分:1)

urllib2.urlopen(url).read().find("<script>alert('alert');</script>") == 0urllib2.urlopen(url).read().find("<script>alert('alert');</script>") >= 0