簡體   English   中英

通過網站上的按鈕下載 Excel 文件 Python

[英]Download Excel File via button on website with Python

我目前正在研究從網站下載 excel 文件的代碼。 相應的文件實際上隱藏在“導出”按鈕后面(參見網站: https://www.amundietf.co.uk/retail/product/view/LU1437018838 )。 但是,我已經確定了以下鏈接: https://www.amundietf.co.uk/retail/ezaap/service/ExportDataProductSheet/Fwd/en-GB/718/LU1437018838/object/export/repartition? idFonctionnel=export-repartition-pie-etf&exportIndex=3&hasDisclaimer=1 由於鏈接不直接指向文件而是執行一些 Java 小部件,我無法通過 python 下載文件。我嘗試了以下代碼:

import re
import requests
link = 'https://www.amundietf.co.uk/retail/ezaap/service/ExportDataProductSheet/Fwd/en-GB/718/LU1437018838/object/export/repartition?idFonctionnel=export-repartition-pie-etf&exportIndex=3&hasDisclaimer=1'

r = requests.get(link, verify= False)

但是,我無法連接到該文件。 有人有這樣做的想法嗎?

我建議使用 HTML:

 <html lang=en> <body> <a href="https://file-examples-com.github.io/uploads/2017/02/file_example_XLSX_10.xlsx" target="_blank">Click here to download</a> </body> </html>

在標簽的href屬性中,可以放自己的excel文件的路徑。 我使用了一個指向我在谷歌上找到的示例文件的外部鏈接。 要在新選項卡中打開,請使用target="_blank"作為屬性。

希望它有效!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM