A parent tag has several siblings, but I can not extract only the text from the parent tag... anyone?

33 views
Skip to first unread message

Felipe Dutra

unread,
Nov 15, 2021, 9:08:15 PM11/15/21
to beautifulsoup
Hey guys,

Can you help, by pointing a solution or a text that I should read? 
Below is a part of the htlm code. I just want the part in yellow, but my code returns the whole thing... 
This code is in a loop looking for all occurrencies on the main container.
>>>     quote = quotes.find('div', class_='quoteText').text

html code
<div class="quoteText">
“Knowledge has to be improved, challenged, and increased constantly, or it vanishes.” <br/> ― <span class="authorOrTitle"> Peter Drucker </span> </div> <span class="authorOrTitle"> Peter Drucker
any help is highly appreciatted! 
Felipe

Felipe Dutra

unread,
Nov 18, 2021, 12:00:39 PM11/18/21
to beautifulsoup
Hey guys! 
I figured it all myself! :)

I used the .content[0] list to get only the text on the parent tag!

>>> quotes = quotess.find('div', class_ = 'quoteText').contents[0]
It worked!

Reply all
Reply to author
Forward
0 new messages