import requests


def _verify_url_exists(url, use_head=False):
    # (str, bool) -> bool
    """
    Verify that the provided URL exists (aka doesn't return 404).
    """
    try:
        if use_head:
            resp = requests.head(url)
        else:
            resp = requests.get(url)
    except requests.exceptions.ConnectionError:
        return False

    return resp.status_code in [200, 302]