从BeautifulSoup获取课程数据

问题描述 投票:0回答:1

我正在尝试使用BeautifulSoup从HTML页面获取类数据。数据如下所示:

    <div class="quoteText">
      &ldquo;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.&rdquo;
  <br>  &#8213;
  <span class="authorOrTitle">
    Marilyn Monroe
  </span>
</div>

我只想要类“ quoteText”下的数据而没有类“ authorOrTitle”中的数据

以下脚本也返回作者的姓名。

for div in soup.find('div', {'class': 'quoteText'}):
    print(div)

如何在没有“ authorOrTitle”类数据的情况下获得“ quoteText”类数据?

谢谢!

python html beautifulsoup html-parsing
1个回答
0
投票

尝试一下,

© www.soinside.com 2019 - 2024. All rights reserved.