Reputation: 49
I have utilised beautiful soup and the class_ to web scrape. When I used find it was ok as I could use get.text() to find the text within the tags. However I want several of the values that are in the following below.
boal_data = boal_soup(class_="investment-info__item grid__item lap--1-2 desk--1-2")
print (boal_data)
This then produces, when you print, the following.
[<div class="investment-info__item grid__item lap--1-2 desk--1-2">
<h2 class="fontsize--p">Investment Date</h2>
<p class="fontsize--h3">Apr 2018</p>
</div>, <div class="investment-info__item grid__item lap--1-2 desk--1-2">
<h2 class="fontsize--p">Country</h2>
<p class="fontsize--h3">Netherlands</p>
</div>, <div class="investment-info__item grid__item lap--1-2 desk--1-2">
<h2 class="fontsize--p">Revenue at ACQ.</h2>
<p class="fontsize--h3">€156m</p>
</div>, <div class="investment-info__item grid__item lap--1-2 desk--1-2">
<h2 class="fontsize--p">Employees at ACQ.</h2>
<p class="fontsize--h3">370</p>
</div>]
I would like to be able to extra the following.
<p class="fontsize--h3">[this text here] </p>
How am I able to do so?
Upvotes: 0
Views: 81
Reputation: 467
use find or find_all to get text of paragraph tag. You can try this
soup.find_all("p","fontsize--h3").getText()
Upvotes: 1