从html源获取下载URL,从content-disposition下载文件

时间:2017-04-28 20:19:03

标签: python html node.js ajax content-disposition

我试图从网站下载Python文件。问题是在页面上提交表单后自动开始下载。使用Mechanize,我可以登录,进入下载所在的页面,填写表单,然后提交表单(开始下载xls文件)。

查看内容处理,我可以看到附件名称:

attachment {'filename': 'policytransactions.xls'}

但我无法弄清楚如何在本地下载此文件。

查看页面源代码,我可以看到我的问题的答案就在这里:

<td><div id="form1:j_idt37" class="ui-datatable ui-widget dataTable"><table role="grid"><thead><tr role="row"><th id="form1:j_idt37:j_idt38" class="ui-state-default" role="columnheader"><div class="ui-dt-c"><span></span></div></th></tr></thead><tfoot></tfoot><tbody id="form1:j_idt37_data" class="ui-datatable-data ui-widget-content"><tr data-ri="0" class="ui-widget-content ui-datatable-even" role="row"><td role="gridcell"><div class="ui-dt-c">
<script type="text/javascript" src="/policy/app/javax.faces.resource/jsf.js?ln=javax.faces"></script>
<a href="#" onclick="mojarra.jsfcljs(document.getElementById('form1'),{'form1:j_idt37:0:j_idt39':'form1:j_idt37:0:j_idt39','format':'xls'},'');return false" class="commandLink"><span class="outputText">XLS</span></a></div></td></tr></tbody></table></div><script id="form1:j_idt37_s" type="text/javascript">PrimeFaces.cw('DataTable','widget_form1_j_idt37',{id:'form1:j_idt37'});</script></td>
<td><table>
<tbody>
<tr>
<td><span id="form1:dateField3"><input id="form1:dateField3_input" name="form1:dateField3_input" type="text" value="04/01/2017" class="ui-inputfield ui-widget ui-state-default ui-corner-all" /></span><script id="form1:dateField3_s" type="text/javascript">$(function(){PrimeFaces.cw('Calendar','widget_form1_dateField3',{id:'form1:dateField3',popup:true,locale:'en_US',dateFormat:'mm/dd/yy',defaultDate:'04/01/2017'});});</script></td>
<td><span id="form1:dateField4"><input id="form1:dateField4_input" name="form1:dateField4_input" type="text" value="04/28/2017" class="ui-inputfield ui-widget ui-state-default ui-corner-all" /></span><script id="form1:dateField4_s" type="text/javascript">$(function(){PrimeFaces.cw('Calendar','widget_form1_dateField4',{id:'form1:dateField4',popup:true,locale:'en_US',dateFormat:'mm/dd/yy',defaultDate:'04/28/2017'});});</script></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="e2s1" />
</form>
</div>

有关如何抓住这个的任何建议?感谢

0 个答案:

没有答案