Web scraping
import requests
from bs4 import BeautifulSoup# Specify the URL you want to scrape
url = 'https://www.example.com'
# Send a GET request to the URL and store the response
response = requests.get(url)
# Parse the HTML content of the response
soup = BeautifulSoup(response.content, 'html.parser')
# Find elements in the HTML using their tags, classes, or IDs
title = soup.find('title').text
heading = soup.find('h1').text
# Print the extracted data
print('Title:', title)
print('Heading:', heading)
Comments
Post a Comment