var fs = require('fs'); var framesWorked = 0; var frameCount = 1; var frameContent = []; var visited_pages = []; var masterURL = ""; var masterPage = null; function newIFrameLoad(page, load_iframes) { var frame_data = []; if (load_iframes) { frame_data = page.evaluate(function () { var framestmp = document.getElementsByTagName('IFRAME'); var frames = []; for (var i=0;i"; } } return frames; }) || []; //This stops the code from crashing incase there is an exception during page eval } var content = new String(page.content); for (var i=0;i '); phantom.exit(); } else { file_name = phantom.args[0]; var loadIframes = phantom.args[1].match(/true/i) ? true : false; address = phantom.args[2]; var argCount = phantom.args[3]; args = "" for (var i=0;i 0) address += '?'+args; console.log("Open page: "+address+", "+args+" END"); console.log('start openning page'); masterURL = address; loadpage(address, undefined, function(page) { masterPage = page; console.log('DONE_LOADING_URL'); //load iframes into page newIFrameLoad(page, loadIframes); if (file_name != null && file_name != "none") { page.render(file_name); } phantom.exit(); }, function(page) { masterPage = page; console.log('FAILED_LOADING_URL: '+status+", "+address); if (file_name != null && file_name != "none") { page.render(file_name); } phantom.exit(); }, function(page) { //page.customHeaders = {"Referer": "http://uk-amazon.icims.com/jobs/240290/account-representative---amazon-web-services---iberia/job"} // page.onResourceReceived = function (response) { // if (response.stage == "end" && response.url == address && response.status != 200) // { // console.log('URL_ERROR_CODE: '+response.status+'URL_ERROR_CODE_END'); // } // }; }); } } main();