Is there a difference between .text and .get_text() in BeautifulSoup ?
Which one should be preferred to get the text of the element?
>>> from bs4 import BeautifulSoup >>> >>> html = "<div>text1 <span>text2</span><div>" >>> soup = BeautifulSoup(html, "html.parser") >>> div = soup.div >>> div.text 'text1 text2' >>> div.get_text() 'text1 text2'
source share