![](/img/trans.png)
[英]Authentication for downloading excel file from direct sharepoint link (python)
[英]Downloading an excel file from a link in python
我在頁面上有一個名為“單擊此處下載”的鏈接,其HTML格式為
<span id="spnDwnRec">
<a class="spnRecordText" onclick="CallExcelFunction()" href="#"> Click here to download all records.</a>
</span>
當我單擊“單擊此處下載”時,將下載一個excel文件,實際上我需要找到鏈接以下載excel文件。
我有下面的代碼的JavaScript功能
function CallExcelFunction() {
var hidInd = document.getElementById('hidInd');
var hidFromDate = document.getElementById('hidFromDate');
var hidToDate = document.getElementById('hidToDate');
var hidDMY = document.getElementById('hidDMY');
window.open('indices_main_excel.aspx?ind=' + hidInd.value + '&fromDate=' + hidFromDate.value + '&toDate=' + hidToDate.value + '&DMY=' + hidDMY.value, '_blank',
'toolbar=yes,location=no, directories=no, status=no, menubar=yes,scrollbars=yes, resizable=yes ,copyhistory=no, width=800, height=600');
}
任何人都可以清除此數據,在此先感謝
當您單擊該按鈕時,將調用javascript函數,並且該函數可能會重定向到文件。
為了能夠使用python下載文件,您要么需要自己找到鏈接(如果您始終下載同一文件),然后使用urllib。 為此,您可以閱讀javascript代碼。
或者您需要使用一些瀏覽器自動化工具(例如,通過python),例如selenium: http : //seleniumhq.org/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.