0

我在一个页面上有一个名为“单击此处下载”的链接,它的 HTML 表单是

<span id="spnDwnRec">
<a class="spnRecordText" onclick="CallExcelFunction()" href="#"> Click here to download all records.</a>
</span>

当我点击“点击这里下载”时,下载了一个 excel 文件,实际上我需要找到下载 excel 文件的链接的 url。

我有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');
}

任何人都可以请清除此数据,提前谢谢

4

1 回答 1

3

当您单击该按钮时,将调用一个 javascript 函数,该函数可能会重定向到该文件。

为了能够用python下载文件,你要么需要自己找到链接(如果你总是下载同一个文件),然后使用urllib。为此,您可以阅读 javascript 代码。

或者您需要使用一些浏览器自动化工具(例如通过 python),例如 selenium:http ://seleniumhq.org/

于 2012-04-24T09:31:05.303 回答