We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi !
I wrote the code below but the HTTP traffic events (onResourceRequested, onResourceReceived) are never fired :
var fs = require('fs'), options, phantomas = require('phantomas'), phantomasTask, ProgressBar = require('progress'), progressBar, startTime, stats, url; url = 'http://www.amazon.com'; options = { "engine": "webkit2", "timeout": 30 }; progressBar = new ProgressBar('Loading ' + url + ' [:bar] :percent (:elapseds)', { complete: '=', incomplete: ' ', width: 20, total: 100 }); console.log(); startTime = Date.now(); phantomasTask = phantomas(url, options); phantomasTask.on('results', function(results) { stats = { "metrics": results.getMetrics(), "requests": { "cssCount": results.getOffenders("cssCount"), "htmlCount": results.getOffenders("htmlCount"), "imageCount": results.getOffenders("imageCount"), "jsCount": results.getOffenders("jsCount"), "otherCount": results.getOffenders("otherCount"), "webfontCount": results.getOffenders("webfontCount") } }; fs.writeFileSync('data/prod/' + Date.now() + '.json', JSON.stringify(stats, undefined, 2)); }); phantomasTask.on('error', function(error) { isNaN(error) ? console.error('Exit error: #%s.', error) : console.error('Exit code: #%d.', error); process.exit(); }); phantomasTask.on('progress', function(progress, progressDiff) { progressBar.tick(progressDiff); }); phantomasTask.on('onResourceRequested', function(request) { console.log(JSON.stringify(request, undefined, 2)); }); phantomasTask.on('onResourceReceived', function(response) { console.log(JSON.stringify(response, undefined, 2)); });
The text was updated successfully, but these errors were encountered:
You should bind to send and recv events. The "core" PhantomJS events are not propagated to phantomas nodejs layer - https://github.com/macbre/phantomas/blob/devel/core/phantomas.js#L623-L631
send
recv
Sorry, something went wrong.
I tried to use them also and it didn't work :s
This is a regression caused by #324 - I'll bring back send and recv events and update the docs on wiki page.
090646e
Fixed
@ivangabriele, thanks for reporting!
And thanks for being so fast to fix it !
No branches or pull requests
Hi !
I wrote the code below but the HTTP traffic events (onResourceRequested, onResourceReceived) are never fired :
The text was updated successfully, but these errors were encountered: