如何通过单击按钮并使用 Python 从特定网站下载 excel 文件?

How to download excel file from a specific website by clicking a button and using Python?

有问题的link是

https://www.de.vanguard/professionell/produktart/etf/aktien/9505/ftse-all-world-ucits-etf-usd-distributing#portfoliodaten

目前我手动点击截图中黄色标记的按钮。我怎样才能改用 Python 下载文件 特定文件夹 重命名

您可以使用硒。设置驱动程序后;

右击按钮,检查。复制完整的 xpath。

driver.get("https://www.de.vanguard/professionell/produktart/etf/aktien/9505/ftse-all-world-ucits-etf-usd-distributing#portfoliodaten")

dlbutton = driver.find_element_by_xpath("/html/body/europe-core-root/europe-core-global-nav/div/europe-core-product-detail-page-component/section[4]/europe-core-market-allocation-container/europe-core-market-allocation/div/div/div[1]/div[2]/europe-core-download-button/button/span")

dlbutton.click()