Welcome to Foundation of Data Science Laboratory
Welcome to Foundation of Data Science Laboratory
Program 4: 1. Parsing a Simple HTML Document
Step 1: Install Required Libraries
pip install requests beautifulsoup4 pandas
from bs4 import BeautifulSoup
html = "<html><head><title>My Title</title></head><body><p>Hello World!</p></body></html>"
soup = BeautifulSoup(html, 'html.parser')
print(soup.title.text) # Output: My Title
print(soup.p.text) # Output: Hello World!
...