Beautiful Soup has the capability of altering completely different properties of the HTML/XML tags. We know that each tag in Beautiful Soup is represented as a Tag
object and it is possible to perform the following tasks:
Modifying the name property of
Tag
Modifying the attribute values of
Tag
Adding new tags
Deleting existing tags
Modifying string contents
A Beautiful Soup Tag
object is always associated with a .name
property; for example, a
, div
, and so on. Modifying the .name
property with a new value will modify the HTML tag as follows:
html_markup = """<div class="ecopyramid"> <ul id="producers"> <li class="producerlist"> <div class="name">plants</div> <div class="number">100000</div> </li> <li class="producerlist"> <div class="name">algae</div> <div class="number">100000</div> </li> </ul>""" soup = BeautifulSoup...