def collapse_whitespace(text):
    if text is None:
        return None
    if hasattr(text, 'xpath'):
        text = text.xpath('string()')
    text = re.sub('\s+', ' ', text)
    return text.strip()
Collapse all consecutive whitespace, newlines and tabs
dataset/ETHPy150Open pudo/scrapekit/scrapekit/util.py/collapse_whitespace