我想从下面的链接下载所有年份的每股收益值(在年度趋势下)。 http://www.bseindia.com/stock-share-price/stockreach_financials.aspx?scripcode=500180&expandable=0
我试着用下面的答案中提到的靓汤。 Extracting table contents from html with python and BeautifulSoup 但无法继续执行以下代码。我觉得我很接近我的答案。任何帮助都将不胜感激。你知道吗
from bs4 import BeautifulSoup
import urllib2
html = urllib2.urlopen("http://www.bseindia.com/stock-share-price/stockreach_financials.aspx?scripcode=500180&expandable=0").read()
soup=BeautifulSoup(html)
table = soup.find('table',{'id' :'acr'})
#the below code wasn't working as I expected it to be
tr = table.find('tr', text='EPS')
我愿意用任何其他语言来完成这件事
文本位于td而不是tr中,因此使用文本获取td,然后调用.parent以获取tr:
你会看到它和页面上的完全匹配。你知道吗
另一种方法是调用查找下一个兄弟姐妹:
相关问题 更多 >
编程相关推荐