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

36 visualizzazioni
Passa al primo messaggio da leggere

Felipe Dutra

da leggere,
15 nov 2021, 21:08:1515/11/21
a 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

da leggere,
18 nov 2021, 12:00:3918/11/21
a 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!

Rispondi a tutti
Rispondi all'autore
Inoltra
0 nuovi messaggi