Python error: NoneType object has no attribute find_all

Python error: NoneType object has no attribute find_all

The error means that the table variable that you are building by doing:

table = BeautifulSoup(r.text).table

is returning None. And for row in table.find_all(tr)[1:]: on a None is throwing the error.

You can check if the url in question has a table in the way you are trying to access it. You can do this by printing out the url constructed by this statement:

BASE_URL.format(row[prefix_1], year, row[prefix_2])

and then going to this url in your browser to check if it has the table of your interest.

Python error: NoneType object has no attribute find_all

Leave a Reply

Your email address will not be published. Required fields are marked *