Skip to content
Advertisement

Getting number of childs of an element with no ID with beatifulsoup

So basically I’m trying to scrape a webpage with Python and I’m getting stucked at finding the number of childs of one element in a list using BeautifulSoup, the HTML of the list follows this:

JavaScript

In my case I want to get the number of tr inside tag tbody, but since it has no id, I found no way to get it with soup and then do a findAll("tr"). Pretty sure this should be easy but can’t find a way, how should I do it?

Advertisement

Answer

You could check the len() of your resultSet from selecting all <tr> in the <tbody>:

JavaScript

Example

JavaScript

Output

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement