How to find all links using BeautifulSoup and Python?
You can find all of the links, anchor
<a> elements, on a web page by using the
find_all function of BeautifulSoup4, with the tag
"a" as a parameter for the function.
Here's a sample code to extract all links from ScrapingBee's blog:
import requests from bs4 import BeautifulSoup response = requests.get("https://www.scrapingbee.com/blog/") soup = BeautifulSoup(response.content, 'html.parser') links = soup.find_all("a") # Find all elements with the tag <a> for link in links: print("Link:", link.get("href"), "Text:", link.string)