我需要用casperjs(1.1.4-1)编写代码以下载带有报告的Excel文件。该链接会调用一些javascript函数,然后这些函数会创建POST来获取文件。
在其他情况下,我已经使用casper.download函数设法下载了文件,但是在这些情况下,我知道URL和用于构建POST请求的变量。在这种情况下,我有点迷路。
这是我要单击并下载的链接
<A onclick=ur_Button_click(event); id=BUTTON_TOOLBAR_2_btn3_acButton title="Export to Microsoft Excel" class=urBtnStd onkeydown=ur_Button_keypress(event); style="OVERFLOW: visible; TEXT-ALIGN: center" href="javascript:void(0);" ct="B" st="" ocl="sapbi_page.sendCommandArray([['ITEM_REF_LIST',null,0,[['ITEM_REF','CHART',1],['ITEM_REF','ANALYSIS',2],['ITEM_REF','EXCEPTIONS',3],['ITEM_REF','QUERY_TITLE',4]]],['EXPORT_FORMAT','XLS',0],['BI_COMMAND_TYPE','EXPORT',0]],event);">Export to Microsoft Excel</A>
在这种情况下,如何建立POST请求并下载生成的Excel文件?
当我单击“导出到Excel”按钮时,可以看到以下输出:
[debug] [phantom] Mouse event 'mousedown' on selector: xpath selector: //*[text()="Export to Microsoft Excel"]
[debug] [phantom] Successfully injected Casper client-side utilities
[debug] [phantom] Mouse event 'mouseup' on selector: xpath selector: //*[text()="Export to Microsoft Excel"]
[debug] [phantom] Mouse event 'click' on selector: xpath selector: //*[text()="Export to Microsoft Excel"]
[info] [phantom] Step anonymous 17/17: done in 40096ms.
[info] [phantom] Done 17 steps in 40097ms
[debug] [phantom] Navigation requested: url=https://portal.site.com/irj/servlet/prt/portal/prtroot/com.sap.ip.bi.web.portal.integration.launcher, type=FormSubmitted, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "about:blank"
我尝试将casper.download与该URL结合使用,但似乎有些参数会遗漏。