Guest User

Untitled

a guest
Feb 22nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. Cache-Control:private,max-age=31536000
  2. Connection:Keep-Alive
  3. Content-Disposition:attachment; filename="report.csv"
  4. Content-Encoding:gzip
  5. Content-Language:de-DE
  6. Content-Type:text/csv; charset=UTF-8
  7. Date:Wed, 22 Jul 2015 12:44:30 GMT
  8. Expires:Thu, 21 Jul 2016 12:44:30 GMT
  9. Keep-Alive:timeout=15, max=75
  10. Pragma:cache
  11. Server:Apache
  12. Transfer-Encoding:chunked
  13. Vary:Accept-Encoding
  14.  
  15. clientRequests.phantomPage.onResourceReceived = function(response) {
  16. console.log('Response (#' + response.id + ', stage "' + response.stage + '"): ' + JSON.stringify(response));
  17. };
  18.  
  19. "contentType": "text/csv; charset=UTF-8",
  20. "headers": {
  21. "name": "Date",
  22. "value": "Wed, 22 Jul 2015 12:57:41 GMT"
  23. },
  24. "name": "Content-Disposition",
  25. "value": "attachment; filename="report.csv"",
  26. "status":200,"statusText":"OK"
  27.  
  28. var fs = require('fs');
  29.  
  30. var page=this;
  31.  
  32. var result = page.evaluate(function() {
  33.  
  34. var out;
  35. $.ajax({
  36. 'async' : false,
  37. 'url' : 'fullurltodownload.csv',
  38. 'success' : function(data, status, xhr) {
  39. out = data;
  40. }
  41. });
  42. return out;
  43.  
  44. });
  45.  
  46. fs.write('mydownloadedfile.csv', result);
  47.  
  48. var casper = require('casper').create();
  49.  
  50. casper.start("http://captaincoffee.com.au/dump/", function() {
  51. this.echo(this.getTitle())
  52. });
  53. casper.then(function(){
  54. var url = 'http://captaincoffee.com.au/dump/csv.csv';
  55. require('utils').dump(this.base64encode(url, 'get'));
  56. });
  57.  
  58. casper.run();
Add Comment
Please, Sign In to add comment