VOOZH about

URL: https://www.geeksforgeeks.org/python/find-the-tag-with-a-given-attribute-value-in-an-html-document-using-beautifulsoup/

⇱ Find the tag with a given attribute value in an HTML document using BeautifulSoup - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Find the tag with a given attribute value in an HTML document using BeautifulSoup

Last Updated : 23 Jul, 2025

Prerequisites: Beautifulsoup

In this article, we will discuss how beautifulsoup can be employed to find a tag with the given attribute value in an HTML document.

Approach:

  • Import module.
  • Scrap data from a webpage.
  • Parse the string scraped to HTML.
  • Use find() function to find the attribute and tag.
  • Print the result.

Syntax: find(attr_name="value")

Below are some implementations of the above approach:

Example 1: 

Output:

div

Example 2:

Output:

a

Example 3:

Output:

p
Comment