0

I have been trying to download a file that come as an attachment from a POST, that is made by a button click. I submit this form, that generate some params (that are not human-friendly), that are only used in the POST to the server.

In Firefox or Chrome, after I click the button a download dialog appears, so I think that the best way to solve this is by setting the headless browser to auto-download, but I can't find a way to do this.

After I click the download button I get this warning from CasperJS:

[warning] [phantom] Loading resource failed with status=fail (HTTP 200): https://myurl.com/report/detail/export
Pedro N
  • 1
  • 1
  • possible duplicate of [casperjs download csv file](http://stackoverflow.com/questions/19199641/casperjs-download-csv-file) – Artjom B. Aug 14 '15 at 19:32
  • I tried this, but the problem is that I have a POST and PARAMS that are generated for me. The problem solves it as a GET. – Pedro N Aug 14 '15 at 19:41
  • You can supply additional request parameters in [`casper.download()`](http://docs.casperjs.org/en/latest/modules/casper.html#download). I'm not sure what the problem is. Please [edit] you question to make it clearer if this doesn't solve your problem. – Artjom B. Aug 14 '15 at 19:45
  • Editing it :) I already tried using some arguments and such, but the problem is is that I don't have access to the http://www.website.com/resource/sheet.xls – Pedro N Aug 14 '15 at 19:47
  • There is no "auto-download" in PhantomJS, so you would need a workaround such as the one I linked to. If you have problems with https URLs, then you should run CasperJS with `--ssl-protocol=tlsv1 --ignore-ssl-errors=true` – Artjom B. Aug 14 '15 at 19:53
  • Yeah, no luck trying that workaround nor using these parameters. I think the main problem is the warning that I just added to the main post, but I can't confirm. – Pedro N Aug 14 '15 at 20:19

0 Answers0