您可以使用
text
或string
属性的元素。elems = soup.find_all(True, class_='template_title')
print([elem.string for elem in elems])
prints
['4']
for the given html snippet根据需要指定更多属性:
elems = soup.find_all(True, class_='template_title', height='50', valign='bottom', width='535')



