import requests from bs4 import BeautifulSoup url = "https://www.example.com" response = requests.get(url) soup = BeautifulSoup(response.content, 'html.parser') title = soup.title.string print(title)
import requests from bs4 import BeautifulSoup url = "https://www.example.com" response = requests.get(url) soup = BeautifulSoup(response.content, 'html.parser') links = soup.find_all('a', href=True) for link in links: print(link['href'])In both of these examples, we used the BeautifulSoup package library to extract data from HTML files.