微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Selenium Firefox xlsx 下载问题

如何解决Selenium Firefox xlsx 下载问题

我正在尝试从此页面提取“导出到 excel”按钮:https://stockanalysis.com/stocks/aapl/financials/

我在 firefox 中使用 selenium,这是我当前的 python3 代码

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
dest_path = 'PATH/TO/DESTINATION/FOLDER/'

# configuring profile
fp = webdriver.FirefoxProfile()
fp.set_preference('browser.download.folderList',2)
fp.set_preference('browser.download.manager.showWhenStarting',False)
fp.set_preference('browser.download.dir',dest_path)
fp.set_preference('browser.helperApps.neverAsk.savetodisk','text/plain,application/vnd.ms-excel,text/csv,application/xls,application/xlsx,text/comma-separated-values,application/octet-stream,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')

driver_firefox = webdriver.Firefox(firefox_profile=fp,executable_path=r"PATH/TO/DRIVERS/geckodriver.exe")
driver_firefox.get("https://stockanalysis.com/stocks/aapl/financials/")
element = driver_firefox.find_element_by_id("expxlxs")
element.click()

我已经能够让弹出窗口消失,但它没有下载目标文件夹中的文件

我做错了什么?有人能帮我解决这个问题吗?

非常感谢!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。