我正在使用以下代码尝试从this URL中的表中提取数据。我问了同样的问题here并得到了答案。但是,尽管当时代码中的代码工作,我现在已经意识到代码中的data
尚未定义,因此下面的代码导致行中的错误AttributeError: 'NoneType' object has no attribute 'text'
final = [[t.th.text] + [ele.text for ele in t.find_all("td")] for t in h[-1].find_all_next("tr")]
。我已经问过用户data
是什么,但我自己无法弄清楚,因此希望在这方面提供一些帮助。
from bs4 import BeautifulSoup
import requests
from itertools import islice
import pandas as pd
r = requests.get(
"http://www.federalreserve.gov/econresdata/researchdata/feds200628_1.html")
soup = BeautifulSoup(r.content)
h = data.find_all("th", scope="col") #Issue
final = [[t.th.text] + [ele.text for ele in t.find_all("td")] for t in h[-1].find_all_next("tr")]
headers = [th.text for th in h]
headers.insert(0,"dates")
df = pd.DataFrame(final,columns=headers)
print df
答案 0 :(得分:1)
rootProject.children.each {
it.buildFileName = it.name + '.gradle'
}