Returns:
Baden-Württemberg
Bayern
Berlin
The builtin python dir() and type() methods are always handy to inspect an object. 
print(dir(names))
[...,
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 'append',
 'clear',
 'copy',
 'count',
 'extend',
 'index',
 'insert',
 'pop',
 'remove',
 'reverse',
 'sort',
 'source']
With a list of comprehension you could do the following :
names = soup.find_all("span",{"class":"toctext"})
print([x.text for x in names])
Post a Comment for "Extract Text From Html File With Beautifulsoup/python"