-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.js
38 lines (33 loc) · 854 Bytes
/
resources.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var casper = require('casper').create();
var target = casper.cli.args[0];
var ua = casper.cli.args[1];
var ignoredResource = casper.cli.args[2];
casper.on('resource.requested', function(requestData, request) {
var uri = requestData['url'];
var i1 = uri.indexOf('?');
var i2 = uri.indexOf(';');
if (i1>0){
uri = uri.substr(0,i1+1);
}
if (i2>0){
uri = uri.substr(0,i2+1);
}
if (uri != ignoredResource) {
casper.echo(uri);
}
else {
request.abort();
}
});
casper.start();
casper.userAgent(ua);
// Open page first time to find all resources
casper.thenOpen(target, function() {
//firstFetch = false;
//casper.echo('Downoading using UA: ' + ua);
//this.echo("loaded");
//this.reload(function() {
// this.echo("loaded again");
//});
});
casper.run();