if isinstance(t, str):
    return ' '.join([_f for _f in t.replace('\n', ' ').split(' ') if _f])
if t.name.lower() == 'br':
    return '\n'
if t.name.lower() == 'script':
    return '\n'
return ''.join(extract_text(c) for c in t)

def extract_text(t):
    return '\n'.join(x.strip() for x in _extract_text(t).split('\n'))
print(extract_text(htmlDom))
Extracting readable text from HTML using Python?