Reputation: 1161
I have an xml which is generated after below beautifulsoup statement. It generates an XML which contains html
and body
tags. I want to remove both html
and body
tags from output. Can I please know how I can achieve the same ?
Code:
soup = bs(''.join(output), "lxml")
print("soup output : {}".format(soup.html))
output:
<html>
<body>
...
</body>
</html>
Upvotes: 1
Views: 230
Reputation: 697
try this:
body = soup.find("body")
innerbody = body.decode_contents()
Upvotes: 3