I want to scrap the data table from the web, and there is an error occurred in for looping statement
below is my code
table_body = soup.find("tbody")
rows = []
for row in table_body.find_all("tr"):
cols = row.find_all("td")
rd = cols[0].text.strip()
mv = cols[1].text.strip()
pb = cols[2].text.strip()
dg = cols[3].text.strip()
wg = cols[4].text.strip()
rows.append([rd, mv, pb, dg, wg])
headers = ["Release Date", "Movie", "Production Budget", "Domestic Gross", "Worldwide Gross"]
and this message error when I have tried running a code
AttributeError Traceback (most recent call last)
Cell In[4], line 4
1 table_body = soup.find("tbody")
2 rows = []
----> 4 for row in table_body.find_all("tr"):
5 cols = row.find_all("td")
6 rd = cols[0].text.strip()
AttributeError: 'NoneType' object has no attribute 'find_all'
what should I do? thanks in advanced
New contributor
Hary is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.