I want to print the "Printable String" part of the code. Also I tried to print the whole tag itself but didn't find a way to print the whole tag instead of just the tag name. Retrieving Xpath and the whole tag itself is the biggest challenge currently, Thank You!
Code:
from bs4 import BeautifulSoup
from lxml import etree
doc = "<p><a></a><a></a>Printable String</p>"
soup = BeautifulSoup(doc, "lxml")
root = etree.fromstring(str(soup))
tree = etree.ElementTree(root)
for i, e in enumerate(root.iter()):
print(e.text)
Output:
None
None
None
None
None
[Finished in 0.2s]
Expected Output:
None
None
Printable String
None
None