So I'm trying to parse quotes from a website, but within the Result class there are multiple paragraphs. Is there a way to ignore the date and author and only select the material in quotes? So I would only be left with a list of quotes? Using BeautifulSoup btw. Thanks.
<div class="result">
<p><strong>Date:</strong> February 2, 2019</p>
<p>"My mind had no choice but to drift into an elaborate fantasy realm."</p>
<blockquote>
<p class="attribution">— Pamela, Paul</p>
</blockquote>
<a href="/metaphors/25249" class="load_details">preview</a> |
<a href="/metaphors/25249" title="Let Children Get Bored Again [from The New York Times]">full record</a>
<div class="details_container"></div>
</div>
<div class="result">
<p><strong>Date:</strong> February 2, 2019</p>
<p>"You let your mind wander and follow it where it goes."</p>
<blockquote>
<p class="attribution">— Pamela, Paul</p>
</blockquote>
<a href="/metaphors/25250" class="load_details">preview</a> |
<a href="/metaphors/25250" title="Let Children Get Bored Again [from The New York Times]">full record</a>
<div class="details_container"></div>
</div>
My current code is here:
import bs4 as bs
import urllib.request
sauce = urllib.request.urlopen('URLHERE').read()
soup = bs.BeautifulSoup(sauce,'lxml')
body = soup.body
for paragraph in body.find_all('p'):
print(paragraph.text)
` but the attribution in a `
– msanford Jul 11 '20 at 02:26