【发布时间】:2011-01-28 22:54:25
【问题描述】:
我正在尝试使用 mechanize/python 从bloomberg 网站下载货币数据。 http://www.bloomberg.com/markets/currencies/
我已设法将字段更新为所需的货币,不幸的是,我在“提交”转换按钮时遇到了麻烦。
我认为 br.submit() 不起作用,当我尝试使用 br.click 时,它说该项目不可点击。 这是按钮的html
<input type="button" value="Convert" class="btn w75" name="button" onclick="calculate(); return false;">
有人建议使用 br.form.action"" (http://bytes.com/topic/python/answers/764326-using-mechanize-python-navigate-website) 但我不确定我会怎么做实施它。
所以这是到目前为止代码的核心......
br = mechanize.Browser() #initialized with and lets cookiejar handle all the cookies stuff
br.open('http://www.bloomberg.com/markets/currencies/')
br.form['from_tkc']=['USD:CUR']
br.form['to_tkc']=['BGN:CUR']
br.submit() .
print br.response().read()
不幸的是,输出 html 没有我需要的数据,即货币计算器,我知道按钮已更新。谁能指出我正确的方向或帮助我更多地理解该按钮。
【问题讨论】:
标签: python button submit mechanize