View Single Post
Old 03-28-2018, 01:36 PM   #400
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,746
Karma: 24032915
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
In bs4, I think there is a get_text() that will work on any element to get all of the text under that element. But I am not 100% on that name.
get_text() is the correct name.

@Maui: If you're looking for a bs4 innerHTML equivalent, you could use decode_contents() to return the inner HTML code of an element:

Code:
soup = BeautifulSoup('<p><a id="x1"></a>Test</p>')
soup.p.decode_contents() 
# returns '<a id="x1"></a>Test'
Doitsu is offline   Reply With Quote