Welcome to Foundation of Data Science Laboratory
Welcome to Foundation of Data Science Laboratory
Program 1:
Step 1: Install Required Libraries
pip install requests beautifulsoup4 pandas
from bs4 import BeautifulSoup
import requests
# Send a request to fetch the web page content
url = "https://example.com"
response = requests.get(url)
# Parse the HTML content
soup = BeautifulSoup(response.content, "html.parser")
# Find and print all the links in the page
for link in soup.find_all('a'):
print(link.get('href'))
Requests to Fetch Webpage Content:
The requests library is used to send a GET request to the URL of the Wikipedia page containing the table.
Parsing HTML with BeautifulSoup:
The response content is parsed using BeautifulSoup with the 'html.parser' option.