I have the following code in main.py
#!/usr/bin/env python
# vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1:
import sys
from bs4 import BeautifulSoup
soup = BeautifulSoup(sys.stdin.read(), 'html.parser')
print type(soup.find('a'))
print str(soup.find('a'))
The result is the following. But I don't want the outmost tag (i.e., and in this case) be printed. Is there a way to robustly print the original string without the outmost tag?
$ ./main.py <<EOF
> <a>x<b>y</b></a>
> EOF
None
<class 'bs4.element.Tag'>
<a>x<b>y</b></a>