January 2014
Beginner
130 pages
2h 37m
English
Beautiful Soup supports the plain printing of the BeautifulSoup and Tag objects. This will return only the plain string without any formatting.
This can be done by using the str() or the
unicode() method.
If we use the str() method on the BeautifulSoup or the Tag object, we get a normal Python string, shown as follows:
print(str(soup)) #output '<html><body><p class="ecopyramid"></p><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></body></html>'
We can use the encode() method that we used in Chapter 6, Encoding Support in Beautiful Soup, to encode the output in a specific ...
Read now
Unlock full access