Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2011-06-21: Version 1.2.0
- run phantomjs ./whateverscript http://fbi.gov
- gettimeofday({1311848791, 76708}, {4294967236, 0}) = 0
- gettimeofday({1311848791, 76734}, {4294967236, 0}) = 0
- gettimeofday({1311848791, 76765}, {4294967236, 0}) = 0
- gettimeofday({1311848791, 76787}, {4294967236, 0}) = 0
- clock_gettime(CLOCK_MONOTONIC, {8641, 606891018}) = 0
- close(36) = 0
- close(34) = 0
- close(35) = 0
- close(28) = 0
- close(29) = 0
- close(30) = 0
- close(31) = 0
- close(32) = 0
- close(33) = 0
- close(27) = 0
- gettimeofday({1311848791, 78629}, {4294967236, 0}) = 0
- gettimeofday({1311848791, 78669}, {4294967236, 0}) = 0
- gettimeofday({1311848791, 78697}, {4294967236, 0}) = 0
- gettimeofday({1311848791, 78745}, {4294967236, 0}) = 0
- gettimeofday({1311848791, 79013}, {4294967236, 0}) = 0
- gettimeofday({1311848791, 79258}, {4294967236, 0}) = 0
- gettimeofday({1311848791, 79389}, {4294967236, 0}) = 0
- gettimeofday({1311848791, 79509}, {4294967236, 0}) = 0
- --- SIGSEGV (Segmentation fault) @ 0 (0) ---
- +++ killed by SIGSEGV +++
- Segmentation fault
- ============script start ==============
- //rip off of netsniff.js in phantomjs examples
- var report =
- {
- consoleLog:'',
- redirectTotal:0,
- requestTotal:0,
- resourceIssues:'1',
- har:null,
- showHarOnError:true,
- console : function(msg)
- {
- this.consoleLog += msg + "\n";
- },
- startLoad : function()
- {
- var d = new Date();
- this.startTime = d.getTime();
- },
- endLoad : function()
- {
- var d = new Date();
- this.endTime = d.getTime();
- },
- build : function(page)
- {
- this.page = page;sc
- this._buildData();
- if (this.resourceIssues)
- {
- if (this.showHarOnError)
- {
- this.har = createHAR(page.address, page.title, page.startTime, page.resources);
- }
- }
- },
- _buildData : function()
- {
- var redirs = 0;
- var requestCount = 0;
- var problems = '';
- this.page.resources.forEach(function (res)
- {
- httpStatus = res.endReply.status;
- requestCount++;
- if (httpStatus == 301 || httpStatus == 302)
- {
- redirs++;
- }
- else if (httpStatus<200 || httpStatus > 299)
- {
- if (httpStatus == null) httpStatus = 'Unknown';
- problems += httpStatus+': '+res.request.url+"\n";
- }
- });
- this.redirectTotal = redirs;
- this.requestTotal = requestCount;
- this.resourceIssues = problems;
- },
- print : function()
- {
- console.log('Page: ' + this.page.address);
- console.log('Load time: ' + (this.endTime - this.startTime) + 'ms');
- console.log('Total requests: ' + this.requestTotal);
- console.log('Total redirects: ' + this.redirectTotal);
- if (this.resourceIssues)
- {
- console.log('Resource Problems');
- console.log(this.resourceIssues);
- }
- if (this.consoleLog)
- {
- console.log('Console');
- console.log(this.consoleLog);
- }
- if (this.har)
- {
- console.log('HAR');
- console.log(JSON.stringify(this.har, undefined, 4));
- }
- }
- }
- printR = function(obj, depth)
- {
- var breakString = '\n';
- var result = '';
- depth = depth ? depth : 0;
- if (obj.constructor)
- {
- for(var k in obj)
- {
- for(var l = 0; l < depth; l++)
- {
- result+=' ';
- }
- if((obj[k]!=null) && (obj[k].constructor == Array|| obj[k].constructor == Object))
- {
- result += k+"=>"+typeof(obj)+"("+breakString+"" + this.printR(obj[k], depth+1)+")"+breakString;
- }
- else
- {
- result += k+"=>"+obj[k]+breakString;
- }
- }
- }
- else
- {
- result = obj + breakString;
- }
- return result;
- }
- if (!Date.prototype.toISOString)
- {
- Date.prototype.toISOString = function ()
- {
- function pad ()
- {
- return n < 10 ? '0' + n : n;
- }
- function ms ()
- {
- return n < 10 ? '00'+ n : n < 100 ? '0' + n : n
- }
- return this.getFullYear() + '-' +
- pad(this.getMonth() + 1) + '-' +
- pad(this.getDate()) + 'T' +
- pad(this.getHours()) + ':' +
- pad(this.getMinutes()) + ':' +
- pad(this.getSeconds()) + '.' +
- ms(this.getMilliseconds()) + 'Z';
- }
- }
- function createHAR(address, title, startTime, resources)
- {
- var entries = [];
- resources.forEach(function (resource)
- {
- var request = resource.request,
- startReply = resource.startReply,
- endReply = resource.endReply;
- if (!request || !startReply || !endReply)
- {
- return;
- }
- entries.push(
- {
- startedDateTime: request.time.toISOString(),
- time: endReply.time - request.time,
- request:
- {
- method: request.method,
- url: request.url,
- httpVersion: "HTTP/1.1",
- cookies: [],
- headers: request.headers,
- queryString: [],
- headersSize: -1,
- bodySize: -1
- },
- response:
- {
- status: endReply.status,
- statusText: endReply.statusText,
- httpVersion: "HTTP/1.1",
- cookies: [],
- headers: endReply.headers,
- redirectURL: "",
- headersSize: -1,
- bodySize: startReply.bodySize,
- content:
- {
- size: startReply.bodySize,
- mimeType: endReply.contentType
- }
- },
- cache: {},
- timings:
- {
- blocked: 0,
- dns: -1,
- connect: -1,
- send: 0,
- wait: startReply.time - request.time,
- receive: endReply.time - startReply.time,
- ssl: -1
- }
- });
- });
- return {
- log:
- {
- version: '1.2',
- creator:
- {
- name: "PhantomJS",
- version: phantom.version.major + '.' + phantom.version.minor +
- '.' + phantom.version.patch
- },
- pages: [
- {
- startedDateTime: startTime.toISOString(),
- id: address,
- title: title,
- pageTimings: {}
- }],
- entries: entries
- }
- };
- }
- if (phantom.args.length === 0)
- {
- console.log('Usage: script.js <some URL>');
- phantom.exit();
- }
- var page = new WebPage();
- page.onConsoleMessage = function (msg, ln, x)
- {
- report.console('"'+msg + '" line: ' +ln + ' file: ' + x);
- };
- page.address = phantom.args[0];
- page.resources = [];
- page.onLoadStarted = function ()
- {
- report.startLoad();
- page.startTime = new Date();
- };
- page.onResourceRequested = function (req)
- {
- page.resources[req.id] =
- {
- request: req
- };
- };
- page.onResourceReceived = function (res)
- {
- if (res.stage === 'start')
- {
- page.resources[res.id].startReply = res;
- }
- if (res.stage === 'end')
- {
- page.resources[res.id].endReply = res;
- }
- };
- page.open(page.address, function (status)
- {
- var har;
- if (status !== 'success')
- {
- console.log('FAIL to load the address '+status);
- }
- else
- {
- report.endLoad();
- page.title = page.evaluate(function ()
- {
- return document.title;
- });
- report.build(page);
- report.print();
- }
- phantom.exit();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement