【发布时间】:2015-02-24 23:20:02
【问题描述】:
所以我对 python 很陌生,我正在尝试使用 bs4 和 urllib 从 iso-ne.com/isoexpress/ 的表中获取数据。到目前为止,这是我所拥有的:
from bs4 import BeautifulSoup
from urllib import urlopen
website='http://www.iso-ne.com/isoexpress/'
html=urlopen(website).read().decode('utf-8')
soup=BeautifulSoup(html, 'html.parser')
table=soup.find('div', {'class': 'chart'})
rows=table.find_all('tr')
for tr in rows:
col=tr.find_all('td')
for td in col:
text=td.find_all(class_='lmp-list-energy')
print text
当我运行这个时,我得到 6 个空括号:
[]
[]
[]
[]
[]
[]
我想要获取的数据是 iso-ne 网站上新罕布什尔州的五分钟实时 LMP 价格
【问题讨论】:
-
我相信这些项目不只是在执行 javascript 之前存在。这就是为什么你不能以这种方式得到它们
标签: python beautifulsoup findall