我正在尝试从表中找到tr
标签。financialStatement
一切正常,直到我编写最后一行代码rows = statement.findAll ( 'tr' )
,它给出:
AttributeError: 'NoneType' object has no attribute 'findAll'
这里的 html 文件: http: //investing.businessweek.com/research/stocks/financials/financials.asp ?ticker=TSCO:LN
import os
import urllib,re
from BeautifulSoup import BeautifulSoup
path = '/Users/projectfile/'
listing = os.listdir(path)
for infile in listing:
print "current file is: " + infile
fileIN = open(path+infile, "r")
line = fileIN.read()
soup = BeautifulSoup ( line )
statement = soup.find ( 'table' , { 'class' : "financialStatement" })
rows = statement.findAll ( 'tr' )