我正在尝试使用BeautifulSoup从HTML页面获取类数据。数据如下所示:
<div class="quoteText">
“I'm selfish, impatient and a little insecure. I make mistakes, I am out of control and at times hard to handle. But if you can't handle me at my worst, then you sure as hell don't deserve me at my best.”
<br> ―
<span class="authorOrTitle">
Marilyn Monroe
</span>
</div>
我只想要类“ quoteText”下的数据而没有类“ authorOrTitle”中的数据
以下脚本也返回作者的姓名。
for div in soup.find('div', {'class': 'quoteText'}):
print(div)
如何在没有“ authorOrTitle”类数据的情况下获得“ quoteText”类数据?
谢谢!
尝试一下,