Reputation:
from bs4 import BeautifulSoup
import re
import urllib2
url = 'http://sports.yahoo.com/nfl/players/5228/gamelog'
page = urllib2.urlopen(url)
soup = BeautifulSoup(page)
table = soup.find(id='player-game_log-season').find('tbody').find_all('tr')
for rows in tr:
data = raws.find_all("td")
print data
I'm trying to go through the table for a certain player's stats last year and grab their stats, however, I get a AttributeError: 'NoneType' object has no attribute 'find_all'
When I try to run this code. I'm new to beautiful soup so I'm not really sure what the problem is.
Also if anyone has any good tutorials to recommend me that would be awesome. Reading through the documentation is sort of confusing as I am fairly new to programming.
Upvotes: 0
Views: 473
Reputation: 369494
There's no tbody
in the table under div#player-game_log-season
. And your code has some typos.
raws
-> rows
table
-> tr
...
tr = soup.find(id='player-game_log-season').find_all('tr')
for rows in tr:
data = rows.find_all("td")
print data
Upvotes: 1