from bs4 import BeautifulSoup import requests url = 'https://www.example.com' page = requests.get(url) soup = BeautifulSoup(page.content, 'html.parser') links = soup.find_all('a') for link in links: print(link.get('href'))
from bs4 import BeautifulSoup import requests url = 'https://www.example.com' page = requests.get(url) soup = BeautifulSoup(page.content, 'html.parser') headings = soup.find_all(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']) for heading in headings: print(heading.text.strip())This code fetches the HTML content of a web page, parses it using BeautifulSoup, and then extracts all the headings on the page using find_all method. Finally, it prints out all the headings on the page. In conclusion, BeautifulSoup is a powerful Python package library for web scraping and parsing HTML/XML documents. Its find_all method is invaluable for extracting data from web pages. It is part of the BeautifulSoup4 package library.