Welcome to Foundation of Data Science Laboratory
Welcome to Foundation of Data Science Laboratory
Program 7: Extracting Attributes from a Tag
Step 1: Install Required Libraries
pip install requests beautifulsoup4 pandas
from bs4 import BeautifulSoup
html = '<html><body><a href="https://example.com">Click Here</a></body></html>'
soup = BeautifulSoup(html, 'html.parser')
link = soup.find('a')
print(link['href']) # Output: https://example.com
...