Javascript Python请求Onclick

Javascript Python请求Onclick,javascript,python,html,web-scraping,python-requests,Javascript,Python,Html,Web Scraping,Python Requests,我已成功登录到一个网站并加载了一个表,然后可以将其作为.xls文件下载。我遇到的问题是,必须单击图像才能调用下载。我还没有弄清楚如何发布正确的数据来获取.xls文件 以下是网站的HTML: <table border="0" width ="95%" align ="center"> <tr> <form name="downloadXLSForm" method="POST" action="/control/filedownload"&

我已成功登录到一个网站并加载了一个表,然后可以将其作为.xls文件下载。我遇到的问题是,必须单击图像才能调用下载。我还没有弄清楚如何发布正确的数据来获取.xls文件

以下是网站的HTML:

 <table border="0" width ="95%" align ="center">
    <tr>
        <form name="downloadXLSForm" method="POST" action="/control/filedownload">
            <input type="hidden" name="fileType" value="mlInventory">
            <td align="left" valign = "top">
                <font face="Verdana, Arial, Helvetica, sans-serif" size="-2">
                    <input type="image" src="../images/excel_download.jpg" onClick="document.downloadXLSForm.submit()" value="Excel Download" Alt="Download the results above into MS Excel">
                </font>
            </td>
        </form>         
        <td align="right" valign = "top">
            <form name="mlInventorysearch" method="post" action="/control/mlinventorysearch">
                <input type="hidden" name="refreshSearch" value="true">
                <input type="submit" value="New Search">
            </form>
        </td>
    </tr>
  </table>
我为这些多余的评论道歉。我在尝试各种组合,看看会发生什么


提前谢谢。我对Python很陌生。

它可以使用
POST
发送额外的数据(可以有隐藏的表单和数据),或者在cookie中包含这些信息。使用Chrome/Firefox中的DevTools查看从浏览器发送到服务器的请求。
with requests.Session() as z:
    z.get("https://www.emlco.com/control/j_security_check", stream=True)
    p3 = z.post("https://www.emlco.com/control/j_security_check",data=payload3) 
    z.get(link)
    inventory_start = z.post(link, data={'newSearch':'true'})
    inventory_excel = z.post(link,data={'fileType':'mlInventory'})
    #inventory_excel = z.post('https://www.emlco.com/control/filedownload',data={'fileType':'mlInventory'})
    inventory_excel = z.get('https://www.emlco.com/control/filedownload', stream = True)
    #output = open('MLCStock.xls', 'wb')
    #output.write(inventory_excel.content)
    #output.close()

    print(inventory_excel.url)
    print(inventory_start.url)
    print("Done")