In Python, which library is commonly used for web scraping and extracting data from websites?

BeautifulSoup
Pandas
Seaborn
Matplotlib

The correct answer is A. BeautifulSoup.

BeautifulSoup is a Python library for parsing HTML and XML documents. It is a popular choice for web scraping because it is easy to use and can handle complex HTML documents.

Pandas is a Python library for data analysis. It is not commonly used for web scraping because it is not designed for that purpose.

Seaborn is a Python library for statistical visualization. It is not commonly used for web scraping because it is not designed for that purpose.

Matplotlib is a Python library for plotting. It is not commonly used for web scraping because it is not designed for that purpose.

Here is an example of how to use BeautifulSoup to scrape data from a website:

“`python
import requests
from bs4 import BeautifulSoup

url = ‘https://www.example.com’

response = requests.get(url)

soup = BeautifulSoup(response.content, ‘html.parser’)

Find all the links on the page

links = soup.find_all(‘a’)

Extract the href attribute from each link

hrefs = [link[‘href’] for link in links]

Print the hrefs

print(hrefs)
“`

This code will print all the links on the page. You can then use these links to scrape data from the website.