Skip to main content
 首页 » 编程设计

python之不安全浏览

2024年10月25日10kerrycode

当尝试访问某些包含恶意内容的网站时,Firefox、Google Chrome 或 Internet Explorer 等浏览器会显示这样一条消息,表明浏览该网站是不安全的,如图所示:



我正在使用 Python 和 Seleinum 在 Firefox、Google Chrome 和 Internet Explorer 中启动一个网站(在 Windows xp 上):如果网站被这些浏览器之一声明为不安全:是否有任何方法可以从浏览器中检索此信息使用Python ?任何想法都非常受欢迎。

请您参考如下方法:

如果你想测试一个网站是否被“标记”为危险使用,你根本不需要 Selenium 。通过他们的查找向 Google Safebrowsing 提出请求 API :

Safe Browsing is a Google service that enables applications to check URLs against Google's constantly updated lists of suspected phishing and malware pages.

当然,还有一个 python wrapper (可以生成 API key here ):

>>> key = 'your own key' 
>>> from safebrowsinglookup import SafebrowsinglookupClient 
>>> client = SafebrowsinglookupClient(key) 
 
>>> client.lookup('http://addonrock.ru/Debugger.js') 
{'http://addonrock.ru/Debugger.js': 'malware'} 
 
>>> client.lookup('http://google.com') 
{'http://google.com': 'ok'}