import requests
import logging


def check_url(url, log=True):
    """Return True if no 404 error on url, else False."""
    try:
        r = requests.get(url)
    except requests.exceptions.SSLError:
        logging.error('No internet access')
        return False
    except requests.exceptions.ConnectionError:
        logging.error('No internet access')
        return False
    if r.status_code != 404:
        if log:
            logging.info('URL Found: {url}'.format(url=url))
        return True
    if log:
        logging.error('404 Not Found: %s' % url)
    return False