Home > Notes > Web Scrapping and BeautiFul Soup

BeautiFul Soup find_all()

Web Scrapping and BeautiFul Soup

Python Request_library Explanation
BeautiFul Soup search()
BeautiFul Soup Introduction and Explanation
BeautiFul Soup find_all()
BeautiFul Soup find()
BeautiFul Soup search()

BeautiFul Soup find_all()

Beautiful Soup find_all()

find_all is used for returning all the matches after scanning the entire document.

# a.) getting all anchor tag
 import requests
 from bs4 import BeautifulSoup
 URL= "https://en.wikipedia.org/wiki/List_of_state_and_union_territo
 page = requests.get(URL)
 soup = BeautifulSoup(page.content,"html")
 #print(soup)
 get_all_anchor_value = soup.find_all("a")
 for i in get_all_anchor_value:
 print(i)

Beautiful Soup find_all()

find_all is used for returning all the matches after scanning the entire document.

 import requests
 from bs4 import BeautifulSoup
 URL= "https://en.wikipedia.org/wiki/List_of_state_and_union_territo
 page = requests.get(URL)
 soup = BeautifulSoup(page.content,"html")
 #print(soup)
 get_all_anchor_value = soup.find_all("a")
 for i in get_all_anchor_value:
 print(i)

getting reference in anchor tag

find_all is used for returning all the matches after scanning the entire document.

 import requests
 from bs4 import BeautifulSoup
 URL= "https://en.wikipedia.org/wiki/List_of_state_and_union_territo
 page = requests.get(URL)
 soup = BeautifulSoup(page.content,"html")
 #print(soup)
 get_all_anchor_value = soup.find_all("a")
 for i in get_all_anchor_value:
 print(i.get("href"))