![]() |
VOOZH | about |
Beautifulsoup is a Python library used for web scraping. This powerful python tool can also be used to modify HTML webpages. This article depicts how beautifulsoup can be employed to extract a div and its content by its ID. For this, find() function of the module is used to find the div by its ID.
Approach:
Syntax : find(tag_name, **kwargs)
Parameters:
- The tag_name argument tell Beautiful Soup to only find tags with given names. Text strings will be ignored, as will tags whose names that don’t match.
- The **kwargs arguments are used to filter against each tag’s ‘id’ attribute.
Below is the implementation:
Example 1:
Output:
Div Content
Example 2:
Output:
Div with id second