Codied To Clipboard !
Home > Notes > Web Scrapping and BeautiFul Soup
The find method is used for finding out the first tag with the specified name or id and returning an object of type bs4.
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_anchoe_value = soup.find("a") print(get_anchoe_value)
find_all is used for returning all the matches after scanning the entire document.
# b.) getting reference in 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.get("href"))
The find method is used for finding out the first tag with the specified name or id and returning an object of type bs4.
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_anchoe_value = soup.find("a") print(get_anchoe_value)