Skip to content Skip to sidebar Skip to footer

Python Beautiful Soup Get Name Of All Classes Inside Html

With python and BS4 I am trying to get the names of all the classes inside a tag. So far my code is rows = table_body.find_all('tr') for row in rows: cols

Solution 1:

If it is as simple as mentioned in your question then just do,

printele.find_all('mark')[0]['class']

However, if you want to filter elements in two parts --- 1. with class and 2. without classes then you may refer to this link of bs4 documentation.

Hope that helps :-)

Post a Comment for "Python Beautiful Soup Get Name Of All Classes Inside Html"