【发布时间】:2013-11-27 19:16:18
【问题描述】:
我如何在以下位置获取基金的价格:
http://www.prudential.com.hk/PruServlet?module=fund&purpose=searchHistFund&fundCd=JAS_U
错了,怎么修改:
import pandas as pd
import requests
import re
url = 'http://www.prudential.com.hk/PruServlet?module=fund&purpose=searchHistFund&fundCd=JAS_U'
tables = pd.read_html(requests.get(url).text, attrs={"class":re.compile("fundPriceCell\d+")})
【问题讨论】:
-
这是一个相当混乱的 html,我认为您将需要探索 xml 树以获取正确的值。 attr 类应该放在桌子上而不是单元格上(我认为)......
-
对不起。这是否意味着我必须导入 BeautifulSoup4?有什么推荐吗?
-
免责声明:我可能是错的,可能有一种巧妙的方法可以让 read_html 抓住它。如果没有,我设想的是这样的:stackoverflow.com/a/16993660/1240268,但它有点混乱/尴尬。
标签: python-2.7 pandas python-requests