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

Popular posts from this blog

Ecommerce website

Yes, Python is an object-oriented programming (OOP) language, but it is also a multi-paradigm language

Your task is to find the missing number.