我正在尝试让我的python脚本检测页面上的警告框
import urllib2
url = raw_input("Please enter your url: ")
if urllib2.urlopen(url).read().find("<script>alert('alert');</script>") == 0:
print "Alert Detected!"
如何让它检测警报?
答案 0 :(得分:1)
urllib2.urlopen(url).read().find("<script>alert('alert');</script>") == 0
来
urllib2.urlopen(url).read().find("<script>alert('alert');</script>") >= 0