Skip to content
forked from ariya/phantomjs

Support download files for phantomjs 2.1 version

License

Notifications You must be signed in to change notification settings

SeNaP/phantomjs

 
 

Repository files navigation

PhantomJS 2.1 - Scriptable Headless WebKit

Support download files

    page.onResourceReceived = function(response) {
    	if(response.contentType =="application/zip"){
    	 	var filename = response.headers[5].value.match(/"(.+?)"/)[1];
    	 	var responseNumber = filename.match(/\d+-\d+/)[0];
    	  	page.onFilePicker = function(){
    		 	console.log("save file:"+filename);
    		    return filename;
    		}
        }
    }

    page.onDownloadFinished = function(status){
    	console.log('onDownloadFinished(' + status + ')');
    }
    page.onLoadFinished = function(status){
        console.log('onLoadFinished(' + status + ')');
    }

page.onInitialized on every frame

    page.onInitialized = function() {

        console.log("INIT ON A FRAME");

    };

About

Support download files for phantomjs 2.1 version

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 82.4%
  • JavaScript 6.1%
  • C++ 5.0%
  • C 3.1%
  • Java 2.2%
  • Python 1.0%
  • Other 0.2%