find() vs find_all()
BeautifulSoup gives you two main search methods. Use find() when you want one element, find_all() when you want many.
soup.find("p") # Returns first <p> element
soup.find_all("p") # Returns list of ALL <p> elements
find() returns a single element (or None if not found). find_all() always returns a list (possibly empty).
This matters when you're looping:
# Get all links on a page
links = soup.find_all("a")
for link in links:
print(link.text)
A common pattern: use find() to locate a container, then find_all() to get items inside it:
table = soup.find("table")
rows = table.find_all("tr")
This two-step approach is essential for real scraping tasks.
Master these patterns in my Web Scraping course.