sopel/tools/web.py

22 lines
571 B
Python
Raw Normal View History

2017-11-22 19:26:40 -05:00
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Some functions for making web interactions easier.
"""
import requests, os
from urllib.parse import urlparse
def secCheck(bot, url):
""" Checks to see if the given link is malicious or not. """
if not urlparse(url).scheme:
hostname = urlparse("//"+url).hostname
else:
hostname = urlparse(url).hostname
# Since bot.memory['safety_cache'] apparently doesn't work.
with open(os.path.join(bot.config.homedir, 'malwaredomains.txt'), 'r') as file:
if hostname in file.read().split():
return None
return url