我正在尝试在我的 python 脚本中实现 Google 安全浏览 API,但无法使其正常工作。代码如下所示
import urllib2
key = 'mykey'
URL = "https://sb-ssl.google.com/safebrowsing/api/lookup?client=python&apikey={key}&appver=1.0&pver=3.0&url={url}"
def is_safe(key, url):
response = urllib2.urlopen(url).read().decode("utf8")
return reponse != 'malware'
print(is_safe(key, 'http://google.com')) #This should return True
print(is_safe(key, 'http://steam.com.co.in')) # This should return False
当我运行代码时,它对两个查询都返回了 True,这不应该是因为第二个 URL 肯定是恶意软件。