It means you try to call find_all
on the value None
. That could be row.tbody
for example, perhaps because there is no <tbody>
in the actual HTML.
Keep in mind that the <tbody>
element is implied. It’ll be visible in your browser’s DOM inspector, but that doesn’t mean it is actually present in the HTML for BeautifulSoup to parse. Generally, you don’t need to reference <tbody>
at all, unless there is also a <thead>
or <tfooter>
or there are multiple <tbody>
elements present.
Just search for the <td>
cells directly:
rows = store.find_all('tr')
for row in rows:
entries = row.find_all('td')
if len(entries) > 6 and entries[6].string is not None:
data.append(entries[6])
You could simplify this by asking for a CSS selector:
rows = soup.select('table:nth-of-type(2) tr')
data = [cell
for row in rows
for cell in row.select('td:nth-of-type(7)') if cell.string]
8
solved AttributeError: ‘NoneType’ object has no attribute ‘find_all’ (Many of the other questions asked weren’t applicable)