from bs4 import BeautifulSoup import requests # make a request to the webpage page = requests.get("https://www.google.com/") # create a BeautifulSoup object soup = BeautifulSoup(page.content, "html.parser") # use findChildren to get all the links on the page links = soup.findChildren("a") # loop through the links and print out the href attribute for link in links: print(link.get("href"))
# same as previous example, but searching for img tags instead of a tags images = soup.findChildren("img") # loop through the images and print out the src attribute for image in images: print(image.get("src"))Overall, BeautifulSoup is a popular Python package library used for web scraping purposes, and the findChildren method is just one example of the useful functionality it provides.