Welcome to Foundation of Data Science Laboratory
Welcome to Foundation of Data Science Laboratory
Program 5: Finding Elements by Tag
Step 1: Install Required Libraries
pip install requests beautifulsoup4 pandas
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup
html = "<html><body><p>First Paragraph</p><p>Second Paragraph</p></body></html>"
soup = BeautifulSoup(html, 'html.parser')
paragraphs = soup.find_all('p') # Find all <p> tags
for p in paragraphs:
print(p.text)
# Output:
# First Paragraph
# Second Paragraph
...