Validates a domain by checking the existance of a <meta name="{prefix}" content="{code}">
    tag in the <head> of the home page of the domain using either HTTP or HTTPs protocols.

    Returns true if verification suceeded.

def check_meta_tag(domain, prefix, code):
    """
    Validates a domain by checking the existance of a <meta name="{prefix}" content="{code}">
    tag in the <head> of the home page of the domain using either HTTP or HTTPs protocols.

    Returns true if verification suceeded.
    """
    url = '://{}'.format(domain)
    for proto in ('http', 'https'):
        try:
            req = Request(proto + url, headers={'User-Agent': 'Mozilla/5.0; Domcheck/1.0'})
            res = urlopen(req, timeout=2)
            if res.code == 200:
                # Expect the </head> to be found in the first 100k of the page
                content = str(res.read(100000))
                res.close()
                return search_meta_tag(content, prefix, code)
            else:
                res.close()
        except:
            logger.debug('', exc_info=True)
    return False