I need the body part of different articles on a page. They've been written in a section tag including several p tags for each paragraph. like:
<section class="...">
<div>...</div>
<figure>...</figure>
<p id='...' class='...'></p>
<p id='...' class='...'></p>
<p id='...' class='...'></p>
</section>
<section class="...">
<div>...</div>
<figure>...</figure>
<p id='...' class='...'></p>
<p id='...' class='...'></p>
<p id='...' class='...'></p>
</section>
If I use code below :
import requests
import re
from bs4 import BeautifulSoup
r = requests.get('url')
all_bodies = soup.find_all('section')
for i in range(len(all_bodies)):
print(all_bodies[i])
It returns the complete content of section and if I add p tag to find_all it returns each p tag as an element of the list, but I want whole p tags of a section in one list element.