Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 825 Bytes

README.md

File metadata and controls

32 lines (26 loc) · 825 Bytes

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");

    };