AttributeError: 'NoneType' object has no attribute 'find_all' (Many of the other questions asked weren't applicable)
<p>I've seen this Error asked on here a few times but the solutions really weren't clear to me. </p>

<p>I am just starting out with BeautifulSoup so this question may be a bit trivial.</p>

<p>I am looking to extract the second table in the following website:</p>

<p><a href="http://www.espnfc.com/player/45843/lionel-messi?season=2015" rel="nofollow">http://www.espnfc.com/player/45843/lionel-messi?season=2015</a></p>

<p>Here is the code I am using to do so:</p>

<pre><code>page = urllib.urlopen('http://www.espnfc.com/player/45843/lionel-messi?season=2015').read()
soup = BeautifulSoup(page, "lxml")

data = []

#find the tables on the webpage
tables = soup.find_all('table')

#extract the table we will be analyzing
store = tables[1]

#extract all of the rows
rows = store.find_all('tr')

for row in rows:

    entries = row.tbody.find_all('td')
    if entries[6].string is not None:
        data.append(entries[6])
</code></pre>

<p>The Attribute Error i'm getting is pointed at <code>entries = row.tbody.find_all('td')</code></p>

<p>Any help would be much appreciated. </p>

<p>It means you try to call <code>find_all</code> on the value <code>None</code>. That could be <code>row.tbody</code> for example, perhaps because there is no <code>&lt;tbody&gt;</code> in the actual HTML.</p>

<p>Keep in mind that the <code>&lt;tbody&gt;</code> element is <em>implied</em>. 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 <em>need</em> to reference <code>&lt;tbody&gt;</code> at all, unless there is also a <code>&lt;thead&gt;</code> or <code>&lt;tfooter&gt;</code> or there are multiple <code>&lt;tbody&gt;</code> elements present.</p>

<p>Just search for the <code>&lt;td&gt;</code> cells directly:</p>

<pre><code>rows = store.find_all('tr')

for row in rows:    
    entries = row.find_all('td')
    if len(entries) &gt; 6 and entries[6].string is not None:
        data.append(entries[6])
</code></pre>

<p>You could simplify this by asking for a <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/#css-selectors" rel="nofollow">CSS selector</a>:</p>

<pre><code>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]
</code></pre>

python beautifulsoup