“ NoneType”对象没有属性“ findAll”。如何解决这个问题?

时间:2019-04-13 18:50:47

标签: python csv beautifulsoup nonetype

我正在尝试将表格下载为CSV文件,但我不断收到 AttributeError:“ NoneType”对象没有属性“ findAll”

from bs4 import BeautifulSoup as BS
import csv
import os

html1t = open("SOUP1.TABLE.ZKILL.HTML").read()
soup1t = BS(html1t)
table1 = soup1t.find('table')

output_rows = []
for table_row in table1.findAll('tr'):
    columns = table_row.find('td')
    output_row = []
    for column in columns:
        output_row.append(column.text)
    output_rows.append(output_row)

with open('./zkillboard1.csv', 'w') as csvfile:
    writer = csv.writer(csvfile)
    writer.writerows(output_rows)

0 个答案:

没有答案