from bs4 import BeautifulSoup import requests url = 'https://www.google.com' response = requests.get(url) soup = BeautifulSoup(response.content, 'html.parser') links = soup.findAll('a') for link in links: print(link.get('href'))
from bs4 import BeautifulSoup import requests url = 'https://www.google.com' response = requests.get(url) soup = BeautifulSoup(response.content, 'html.parser') images = soup.findAll('img') for image in images: print(image.get('src'))This code is similar to the previous example, but instead finds all the `` tags (i.e. images) on the Google homepage and prints out the URL for each image. Overall, BeautifulSoup is a really powerful package for parsing HTML and XML documents in Python. It's commonly used in web scraping to scrape data from websites. The package library for BeautifulSoup is `bs4`.