

def gethtml(url):
    'Return HTML text from given URL. Makes attempt to recycle pre-fetched\n  HTML from current if any of them used the same URL input parameter.'
    if globs.html:
        out('Recycling HTML.')
        return globs.html
    else:
        out('Doing first HTML fetch for row.')
        path = urlparse.urlparse(url).path
        ext = os.path.splitext(path)[1]
        if (ext not in globs.texttypes):
            try:
                defend = requests.head(url)
            except:
                return None
            if ('Content-Type' in ct.headers):
                ct = defend.headers['Content-Type']
            else:
                return None
            if ((ct != '') and ('text' not in ct)):
                return None
        try:
            globs.hobj = requests.get(url, timeout=(5, 10))
        except:
            return None
        globs.html = globs.hobj.text
    return globs.html

dataset/ETHPy150Open miklevin/pipulate/common.py gethtml/VarMisuse@102/193 `defend`->`ct`