Tag Object – Python Beautifulsoup
Tag object is provided by Beautiful Soup which is a web scraping framework for Python. Web scraping is the process of extracting data from the website using automated tools to make the process faster. Tag object corresponds to an XML or HTML tag in the original document. Further, this object is usually used to extract a tag from the whole HTML document. Further, Beautiful Soup is not an HTTP client which means to scrap online websites you first have to download them using requests module and then serve it to Beautiful Soup for scraping. Additionally, this object returns the first found tag if your document have multiple tags with the same name.
Prerequisite: Beautiful Soup Installation
Parameters: This function doesn’t accept any parameter.
Below given examples explain the concept of Tag object in Beautiful Soup.
Example 1: In this example we are going to extract h1 tag element only.
<h1>a web page</h1>
Example 2: In this example we are going to see the type of strong tag element only.
Example 3: In this example we are going to see the output from a HTML with multiple tags.
<strong>the first strong tag</strong>
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course