Phantomjs lets you add hooks when it fetches a web page. Here is code snippet which can be used to print all resources phantomjs fetches after fetching the main page.
var url = require('system').args[1];
var page = require('webpage').create();
page.onResourceRequested = function (requestData, request) {
console.log('url requested: ' + requestData.url);
};
page.open(url, function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
console.log("Done...");
phantom.exit(0);
}
});Save above code as resources.js and run
phantomjs resources.js https://dev.infoheap.com/
Here is the sample outcome (first few lines) which come from running this on Ubuntu Linix:
url requested: https://dev.infoheap.com/ url requested: https://dev.infoheap.com/wp-content/plugins/yet-another-related-posts-plugin/style/widget.css?ver=4.3.1 url requested: https://dev.infoheap.com/wp-content/themes/shell-master/style.css?ver=0.1.1 url requested: https://dev.infoheap.com/wp-content/themes/shell-master/media-queries.css?ver=0.1.1 url requested: https://dev.infoheap.com/wp-content/themes/shell-child-colorful/style.css?ver=0.0.1 url requested: https://dev.infoheap.com/wp-includes/js/jquery/jquery.js?ver=1.11.3 url requested: https://dev.infoheap.com/wp-includes/js/jquery/jquery-migrate.js?ver=1.2.1 url requested: http://www.google-analytics.com/analytics.js ...