def get_texts(soup, strip = False, types = (NavigableString, CData)): texts = [] for s in soup._all_strings(strip, types = types): texts.append(s) return texts