I want to extract the text within list element inside a comment without the list tags.But I can't do it with the code below.
from bs4 import BeautifulSoup, Comment
html = """
<html>
<body>
<!--
<ul>
<li>10</li>
<li>20</li>
<li>30</li>
</ul>
-->
</body>
</html>
"""
soup = BeautifulSoup(html, 'html.parser')
for numbers in soup.findAll(text=lambda text:isinstance(text, Comment)):
print(numbers.extract())
Result is:
<ul>
<li>10</li>
<li>20</li>
<li>30</li>
</ul>
Desired result :
10
20
30