使用 Python 和 Selenium 进行网页抓取 Fidelity.com 无法单击按钮

时间:2021-03-22 15:26:14

标签: python selenium web-scraping

我已经开始使用 Selenium 在 Python 中创建一个脚本来抓取我在 Fidelity.com 上的帐户 我可以登录并点击网页上的某些按钮,但以下按钮代码有问题。

Download = driver.find_element_by_xpath("//button[@id='posweb-share-button']") 下载.click()

这是html:

<button id="posweb-share-button" class="posweb-share-button pvd-btn btn-anchor posweb-metrics" type="button" aria-label="Download and Print Positions data" data-metrics="shareIcon" aria-describedby="posweb-share-popover"><pvd-icon icon="share" label="Download and Print" aria-hidden="true"></pvd-icon></button>

登录的代码找到了,我想用代码点击网页上的其他按钮,但是上面的代码没有任何反应,我得到“进程完成,退出代码0”。

1 个答案:

答案 0 :(得分:0)

如果您将其存储为变量,您需要像这样分隔代码:

Download = driver.find_element_by_xpath("//button[@id='posweb-share-button']")
Download.click()
相关问题