首页 > 解决方案 > 如何使用 python 2.7 检测红旗、网络钓鱼或恶意站点?

问题描述

我想使用 python 检测恶意网站。

现在,我尝试使用requests模块来获取网站的内容,然后在其中进行搜索malicious words。但是,我没有让它工作。

这里是红页的示例图片

这是我的所有代码:链接代码

req_check = requests.get(url)

    if 'malicious words' in req_check.content:
        print ('[Your Site Detect Red Page]   ===>   '+url)
    else:
        print ('[Your Site Not Detect Red Page]   ===>   '+url)

标签: pythonpython-2.7

解决方案


它不起作用,因为您使用requests错误的库。

在您的代码中,您基本上只能获得病毒站点的 HTML(代码行:req_check = requests.get(url, verify=False)if 'example for detect ' in req_check.content:{source: https://pastebin.com/6x24SN6v })

在 Chrome 中,浏览器会运行已知病毒链接的数据库(比这更复杂)并查看链接是否安全。但是,requests图书馆这样做。相反,您最好使用他们的 API。requests如果您想了解 API 如何

旁注,redage()从未调用过?


推荐阅读