phantomjs.rb 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG +11 -0
- data/MIT-LICENSE +21 -0
- data/lib/phantomjs.rb +4 -2
- data/lib/phantomjs/version.rb +1 -1
- data/phantomjs.rb.gemspec +5 -1
- metadata +20 -186
- data/vendor/phantomjs-1.4.1_OSX/ChangeLog +0 -145
- data/vendor/phantomjs-1.4.1_OSX/LICENSE.BSD +0 -22
- data/vendor/phantomjs-1.4.1_OSX/README.md +0 -33
- data/vendor/phantomjs-1.4.1_OSX/bin/Info.plist +0 -12
- data/vendor/phantomjs-1.4.1_OSX/bin/phantomjs +0 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/arguments.coffee +0 -6
- data/vendor/phantomjs-1.4.1_OSX/examples/arguments.js +0 -8
- data/vendor/phantomjs-1.4.1_OSX/examples/colorwheel.coffee +0 -46
- data/vendor/phantomjs-1.4.1_OSX/examples/colorwheel.js +0 -51
- data/vendor/phantomjs-1.4.1_OSX/examples/countdown.coffee +0 -8
- data/vendor/phantomjs-1.4.1_OSX/examples/countdown.js +0 -9
- data/vendor/phantomjs-1.4.1_OSX/examples/detectsniff.coffee +0 -40
- data/vendor/phantomjs-1.4.1_OSX/examples/detectsniff.js +0 -57
- data/vendor/phantomjs-1.4.1_OSX/examples/direction.coffee +0 -29
- data/vendor/phantomjs-1.4.1_OSX/examples/direction.js +0 -34
- data/vendor/phantomjs-1.4.1_OSX/examples/echoToFile.coffee +0 -19
- data/vendor/phantomjs-1.4.1_OSX/examples/echoToFile.js +0 -22
- data/vendor/phantomjs-1.4.1_OSX/examples/features.js +0 -30
- data/vendor/phantomjs-1.4.1_OSX/examples/fibo.coffee +0 -8
- data/vendor/phantomjs-1.4.1_OSX/examples/fibo.js +0 -9
- data/vendor/phantomjs-1.4.1_OSX/examples/follow.coffee +0 -54
- data/vendor/phantomjs-1.4.1_OSX/examples/follow.js +0 -59
- data/vendor/phantomjs-1.4.1_OSX/examples/hello.coffee +0 -2
- data/vendor/phantomjs-1.4.1_OSX/examples/hello.js +0 -2
- data/vendor/phantomjs-1.4.1_OSX/examples/imagebin.coffee +0 -19
- data/vendor/phantomjs-1.4.1_OSX/examples/imagebin.js +0 -22
- data/vendor/phantomjs-1.4.1_OSX/examples/injectme.coffee +0 -23
- data/vendor/phantomjs-1.4.1_OSX/examples/injectme.js +0 -25
- data/vendor/phantomjs-1.4.1_OSX/examples/ipgeocode.coffee +0 -13
- data/vendor/phantomjs-1.4.1_OSX/examples/ipgeocode.js +0 -14
- data/vendor/phantomjs-1.4.1_OSX/examples/loadspeed.coffee +0 -17
- data/vendor/phantomjs-1.4.1_OSX/examples/loadspeed.js +0 -22
- data/vendor/phantomjs-1.4.1_OSX/examples/modernizr.js +0 -1116
- data/vendor/phantomjs-1.4.1_OSX/examples/movies.coffee +0 -13
- data/vendor/phantomjs-1.4.1_OSX/examples/movies.js +0 -14
- data/vendor/phantomjs-1.4.1_OSX/examples/netlog.coffee +0 -17
- data/vendor/phantomjs-1.4.1_OSX/examples/netlog.js +0 -23
- data/vendor/phantomjs-1.4.1_OSX/examples/netsniff.coffee +0 -109
- data/vendor/phantomjs-1.4.1_OSX/examples/netsniff.js +0 -131
- data/vendor/phantomjs-1.4.1_OSX/examples/outputEncoding.coffee +0 -12
- data/vendor/phantomjs-1.4.1_OSX/examples/outputEncoding.js +0 -16
- data/vendor/phantomjs-1.4.1_OSX/examples/phantomwebintro.coffee +0 -13
- data/vendor/phantomjs-1.4.1_OSX/examples/phantomwebintro.js +0 -19
- data/vendor/phantomjs-1.4.1_OSX/examples/pizza.coffee +0 -18
- data/vendor/phantomjs-1.4.1_OSX/examples/pizza.js +0 -20
- data/vendor/phantomjs-1.4.1_OSX/examples/post.coffee +0 -12
- data/vendor/phantomjs-1.4.1_OSX/examples/post.js +0 -14
- data/vendor/phantomjs-1.4.1_OSX/examples/rasterize.coffee +0 -22
- data/vendor/phantomjs-1.4.1_OSX/examples/rasterize.js +0 -27
- data/vendor/phantomjs-1.4.1_OSX/examples/render_multi_url.coffee +0 -48
- data/vendor/phantomjs-1.4.1_OSX/examples/render_multi_url.js +0 -60
- data/vendor/phantomjs-1.4.1_OSX/examples/run-jasmine.coffee +0 -59
- data/vendor/phantomjs-1.4.1_OSX/examples/run-jasmine.js +0 -77
- data/vendor/phantomjs-1.4.1_OSX/examples/run-qunit.coffee +0 -62
- data/vendor/phantomjs-1.4.1_OSX/examples/run-qunit.js +0 -74
- data/vendor/phantomjs-1.4.1_OSX/examples/scandir.coffee +0 -15
- data/vendor/phantomjs-1.4.1_OSX/examples/scandir.js +0 -21
- data/vendor/phantomjs-1.4.1_OSX/examples/seasonfood.coffee +0 -17
- data/vendor/phantomjs-1.4.1_OSX/examples/seasonfood.js +0 -19
- data/vendor/phantomjs-1.4.1_OSX/examples/simpleserver.coffee +0 -35
- data/vendor/phantomjs-1.4.1_OSX/examples/simpleserver.js +0 -40
- data/vendor/phantomjs-1.4.1_OSX/examples/sleepsort.coffee +0 -17
- data/vendor/phantomjs-1.4.1_OSX/examples/sleepsort.js +0 -24
- data/vendor/phantomjs-1.4.1_OSX/examples/technews.coffee +0 -17
- data/vendor/phantomjs-1.4.1_OSX/examples/technews.js +0 -16
- data/vendor/phantomjs-1.4.1_OSX/examples/tweets.coffee +0 -30
- data/vendor/phantomjs-1.4.1_OSX/examples/tweets.js +0 -36
- data/vendor/phantomjs-1.4.1_OSX/examples/unrandomize.coffee +0 -18
- data/vendor/phantomjs-1.4.1_OSX/examples/unrandomize.js +0 -24
- data/vendor/phantomjs-1.4.1_OSX/examples/useragent.coffee +0 -11
- data/vendor/phantomjs-1.4.1_OSX/examples/useragent.js +0 -14
- data/vendor/phantomjs-1.4.1_OSX/examples/version.coffee +0 -5
- data/vendor/phantomjs-1.4.1_OSX/examples/version.js +0 -5
- data/vendor/phantomjs-1.4.1_OSX/examples/waitfor.coffee +0 -48
- data/vendor/phantomjs-1.4.1_OSX/examples/waitfor.js +0 -57
- data/vendor/phantomjs-1.4.1_OSX/examples/weather.coffee +0 -48
- data/vendor/phantomjs-1.4.1_OSX/examples/weather.js +0 -57
- data/vendor/phantomjs-1.4.1_OSX/lib/jquery.js +0 -8374
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/ChangeLog +0 -177
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/LICENSE.BSD +0 -22
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/README.md +0 -33
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/bin/Info.plist +0 -12
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/bin/phantomjs +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/arguments.coffee +0 -7
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/arguments.js +0 -9
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/colorwheel.coffee +0 -46
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/colorwheel.js +0 -51
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/countdown.coffee +0 -8
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/countdown.js +0 -9
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/detectsniff.coffee +0 -41
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/detectsniff.js +0 -58
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/direction.coffee +0 -30
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/direction.js +0 -35
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.coffee +0 -20
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.js +0 -24
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/features.js +0 -30
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/fibo.coffee +0 -8
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/fibo.js +0 -9
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/follow.coffee +0 -29
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/follow.js +0 -34
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/hello.coffee +0 -2
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/hello.js +0 -2
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/imagebin.coffee +0 -20
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/imagebin.js +0 -23
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.coffee +0 -23
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.js +0 -25
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/ipgeocode.coffee +0 -13
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/ipgeocode.js +0 -14
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/loadspeed.coffee +0 -18
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/loadspeed.js +0 -23
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/modernizr.js +0 -1116
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/movies.coffee +0 -13
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/movies.js +0 -14
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netlog.coffee +0 -18
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netlog.js +0 -25
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netsniff.coffee +0 -110
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netsniff.js +0 -132
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/outputEncoding.coffee +0 -12
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/outputEncoding.js +0 -16
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/phantomwebintro.coffee +0 -13
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/phantomwebintro.js +0 -19
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/pizza.coffee +0 -18
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/pizza.js +0 -20
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/post.coffee +0 -12
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/post.js +0 -14
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/postserver.js +0 -34
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/printenv.js +0 -10
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/printmargins.js +0 -35
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/rasterize.coffee +0 -23
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/rasterize.js +0 -28
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/render_multi_url.coffee +0 -50
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/render_multi_url.js +0 -62
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-jasmine.coffee +0 -61
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-jasmine.js +0 -79
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-qunit.coffee +0 -64
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-qunit.js +0 -76
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/scandir.coffee +0 -16
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/scandir.js +0 -22
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/seasonfood.coffee +0 -17
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/seasonfood.js +0 -19
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/server.js +0 -43
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/serverkeepalive.js +0 -34
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/simpleserver.coffee +0 -38
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/simpleserver.js +0 -42
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/sleepsort.coffee +0 -20
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/sleepsort.js +0 -25
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/technews.coffee +0 -17
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/technews.js +0 -16
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/tweets.coffee +0 -31
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/tweets.js +0 -37
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/unrandomize.coffee +0 -18
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/unrandomize.js +0 -24
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/useragent.coffee +0 -11
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/useragent.js +0 -14
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/version.coffee +0 -5
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/version.js +0 -5
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/waitfor.coffee +0 -48
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/waitfor.js +0 -57
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/weather.coffee +0 -49
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/weather.js +0 -58
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.la +0 -28
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.prl +0 -7
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4.8 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4.8.0 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.la +0 -28
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.prl +0 -7
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4.8 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4.8.0 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.la +0 -28
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.prl +0 -7
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4.8 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4.8.0 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.la +0 -28
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.prl +0 -6
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4.9 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4.9.0 +0 -0
@@ -1,13 +0,0 @@
|
|
1
|
-
# List movies from kids-in-mind.com
|
2
|
-
|
3
|
-
window.cbfunc = (data) ->
|
4
|
-
globaldata = data
|
5
|
-
list = data.query.results.movie
|
6
|
-
for item in list
|
7
|
-
console.log item.title + ' [' + item.rating.MPAA.content + ']'
|
8
|
-
phantom.exit()
|
9
|
-
|
10
|
-
el = document.createElement 'script'
|
11
|
-
el.src =
|
12
|
-
"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20movies.kids-in-mind&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=window.cbfunc"
|
13
|
-
document.body.appendChild el
|
@@ -1,14 +0,0 @@
|
|
1
|
-
// List movies from kids-in-mind.com
|
2
|
-
|
3
|
-
var cbfunc = function (data) {
|
4
|
-
globaldata= data;
|
5
|
-
var list = data.query.results.movie;
|
6
|
-
list.forEach(function (item) {
|
7
|
-
console.log(item.title + ' [' + item.rating.MPAA.content + ']');
|
8
|
-
});
|
9
|
-
phantom.exit();
|
10
|
-
};
|
11
|
-
|
12
|
-
var el = document.createElement('script');
|
13
|
-
el.src = 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20movies.kids-in-mind&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=cbfunc';
|
14
|
-
document.body.appendChild(el);
|
@@ -1,18 +0,0 @@
|
|
1
|
-
page = require('webpage').create()
|
2
|
-
system = require 'system'
|
3
|
-
|
4
|
-
if system.args.length is 1
|
5
|
-
console.log 'Usage: netlog.coffee <some URL>'
|
6
|
-
phantom.exit()
|
7
|
-
else
|
8
|
-
address = system.args[1]
|
9
|
-
page.onResourceRequested = (req) ->
|
10
|
-
console.log 'requested ' + JSON.stringify(req, undefined, 4)
|
11
|
-
|
12
|
-
page.onResourceReceived = (res) ->
|
13
|
-
console.log 'received ' + JSON.stringify(res, undefined, 4)
|
14
|
-
|
15
|
-
page.open address, (status) ->
|
16
|
-
if status isnt 'success'
|
17
|
-
console.log 'FAIL to load the address'
|
18
|
-
phantom.exit()
|
@@ -1,25 +0,0 @@
|
|
1
|
-
var page = require('webpage').create(),
|
2
|
-
system = require('system'),
|
3
|
-
address;
|
4
|
-
|
5
|
-
if (system.args.length === 1) {
|
6
|
-
console.log('Usage: netlog.js <some URL>');
|
7
|
-
phantom.exit();
|
8
|
-
} else {
|
9
|
-
address = system.args[1];
|
10
|
-
|
11
|
-
page.onResourceRequested = function (req) {
|
12
|
-
console.log('requested: ' + JSON.stringify(req, undefined, 4));
|
13
|
-
};
|
14
|
-
|
15
|
-
page.onResourceReceived = function (res) {
|
16
|
-
console.log('received: ' + JSON.stringify(res, undefined, 4));
|
17
|
-
};
|
18
|
-
|
19
|
-
page.open(address, function (status) {
|
20
|
-
if (status !== 'success') {
|
21
|
-
console.log('FAIL to load the address');
|
22
|
-
}
|
23
|
-
phantom.exit();
|
24
|
-
});
|
25
|
-
}
|
@@ -1,110 +0,0 @@
|
|
1
|
-
if not Date::toISOString
|
2
|
-
Date::toISOString = ->
|
3
|
-
pad = (n) ->
|
4
|
-
if n < 10 then '0' + n else n
|
5
|
-
ms = (n) ->
|
6
|
-
if n < 10 then '00' + n else (if n < 100 then '0' + n else n)
|
7
|
-
@getFullYear() + '-' +
|
8
|
-
pad(@getMonth() + 1) + '-' +
|
9
|
-
pad(@getDate()) + 'T' +
|
10
|
-
pad(@getHours()) + ':' +
|
11
|
-
pad(@getMinutes()) + ':' +
|
12
|
-
pad(@getSeconds()) + '.' +
|
13
|
-
ms(@getMilliseconds()) + 'Z'
|
14
|
-
|
15
|
-
createHAR = (address, title, startTime, resources) ->
|
16
|
-
entries = []
|
17
|
-
|
18
|
-
resources.forEach (resource) ->
|
19
|
-
request = resource.request
|
20
|
-
startReply = resource.startReply
|
21
|
-
endReply = resource.endReply
|
22
|
-
|
23
|
-
if not request or not startReply or not endReply
|
24
|
-
return
|
25
|
-
|
26
|
-
entries.push
|
27
|
-
startedDateTime: request.time.toISOString()
|
28
|
-
time: endReply.time - request.time
|
29
|
-
request:
|
30
|
-
method: request.method
|
31
|
-
url: request.url
|
32
|
-
httpVersion: 'HTTP/1.1'
|
33
|
-
cookies: []
|
34
|
-
headers: request.headers
|
35
|
-
queryString: []
|
36
|
-
headersSize: -1
|
37
|
-
bodySize: -1
|
38
|
-
|
39
|
-
response:
|
40
|
-
status: endReply.status
|
41
|
-
statusText: endReply.statusText
|
42
|
-
httpVersion: 'HTTP/1.1'
|
43
|
-
cookies: []
|
44
|
-
headers: endReply.headers
|
45
|
-
redirectURL: ''
|
46
|
-
headersSize: -1
|
47
|
-
bodySize: startReply.bodySize
|
48
|
-
content:
|
49
|
-
size: startReply.bodySize
|
50
|
-
mimeType: endReply.contentType
|
51
|
-
|
52
|
-
cache: {}
|
53
|
-
timings:
|
54
|
-
blocked: 0
|
55
|
-
dns: -1
|
56
|
-
connect: -1
|
57
|
-
send: 0
|
58
|
-
wait: startReply.time - request.time
|
59
|
-
receive: endReply.time - startReply.time
|
60
|
-
ssl: -1
|
61
|
-
|
62
|
-
log:
|
63
|
-
version: '1.2'
|
64
|
-
creator:
|
65
|
-
name: 'PhantomJS'
|
66
|
-
version: phantom.version.major + '.' + phantom.version.minor + '.' + phantom.version.patch
|
67
|
-
|
68
|
-
pages: [
|
69
|
-
startedDateTime: startTime.toISOString()
|
70
|
-
id: address
|
71
|
-
title: title
|
72
|
-
pageTimings: {}
|
73
|
-
]
|
74
|
-
entries: entries
|
75
|
-
|
76
|
-
page = require('webpage').create()
|
77
|
-
system = require 'system'
|
78
|
-
|
79
|
-
if system.args.length is 1
|
80
|
-
console.log 'Usage: netsniff.coffee <some URL>'
|
81
|
-
phantom.exit()
|
82
|
-
else
|
83
|
-
page.address = system.args[1]
|
84
|
-
page.resources = []
|
85
|
-
|
86
|
-
page.onLoadStarted = ->
|
87
|
-
page.startTime = new Date()
|
88
|
-
|
89
|
-
page.onResourceRequested = (req) ->
|
90
|
-
page.resources[req.id] =
|
91
|
-
request: req
|
92
|
-
startReply: null
|
93
|
-
endReply: null
|
94
|
-
|
95
|
-
page.onResourceReceived = (res) ->
|
96
|
-
if res.stage is 'start'
|
97
|
-
page.resources[res.id].startReply = res
|
98
|
-
if res.stage is 'end'
|
99
|
-
page.resources[res.id].endReply = res
|
100
|
-
|
101
|
-
page.open page.address, (status) ->
|
102
|
-
if status isnt 'success'
|
103
|
-
console.log 'FAIL to load the address'
|
104
|
-
else
|
105
|
-
page.title = page.evaluate ->
|
106
|
-
document.title
|
107
|
-
|
108
|
-
har = createHAR page.address, page.title, page.startTime, page.resources
|
109
|
-
console.log JSON.stringify har, undefined, 4
|
110
|
-
phantom.exit()
|
@@ -1,132 +0,0 @@
|
|
1
|
-
if (!Date.prototype.toISOString) {
|
2
|
-
Date.prototype.toISOString = function () {
|
3
|
-
function pad(n) { return n < 10 ? '0' + n : n; }
|
4
|
-
function ms(n) { return n < 10 ? '00'+ n : n < 100 ? '0' + n : n }
|
5
|
-
return this.getFullYear() + '-' +
|
6
|
-
pad(this.getMonth() + 1) + '-' +
|
7
|
-
pad(this.getDate()) + 'T' +
|
8
|
-
pad(this.getHours()) + ':' +
|
9
|
-
pad(this.getMinutes()) + ':' +
|
10
|
-
pad(this.getSeconds()) + '.' +
|
11
|
-
ms(this.getMilliseconds()) + 'Z';
|
12
|
-
}
|
13
|
-
}
|
14
|
-
|
15
|
-
function createHAR(address, title, startTime, resources)
|
16
|
-
{
|
17
|
-
var entries = [];
|
18
|
-
|
19
|
-
resources.forEach(function (resource) {
|
20
|
-
var request = resource.request,
|
21
|
-
startReply = resource.startReply,
|
22
|
-
endReply = resource.endReply;
|
23
|
-
|
24
|
-
if (!request || !startReply || !endReply) {
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
|
28
|
-
entries.push({
|
29
|
-
startedDateTime: request.time.toISOString(),
|
30
|
-
time: endReply.time - request.time,
|
31
|
-
request: {
|
32
|
-
method: request.method,
|
33
|
-
url: request.url,
|
34
|
-
httpVersion: "HTTP/1.1",
|
35
|
-
cookies: [],
|
36
|
-
headers: request.headers,
|
37
|
-
queryString: [],
|
38
|
-
headersSize: -1,
|
39
|
-
bodySize: -1
|
40
|
-
},
|
41
|
-
response: {
|
42
|
-
status: endReply.status,
|
43
|
-
statusText: endReply.statusText,
|
44
|
-
httpVersion: "HTTP/1.1",
|
45
|
-
cookies: [],
|
46
|
-
headers: endReply.headers,
|
47
|
-
redirectURL: "",
|
48
|
-
headersSize: -1,
|
49
|
-
bodySize: startReply.bodySize,
|
50
|
-
content: {
|
51
|
-
size: startReply.bodySize,
|
52
|
-
mimeType: endReply.contentType
|
53
|
-
}
|
54
|
-
},
|
55
|
-
cache: {},
|
56
|
-
timings: {
|
57
|
-
blocked: 0,
|
58
|
-
dns: -1,
|
59
|
-
connect: -1,
|
60
|
-
send: 0,
|
61
|
-
wait: startReply.time - request.time,
|
62
|
-
receive: endReply.time - startReply.time,
|
63
|
-
ssl: -1
|
64
|
-
}
|
65
|
-
});
|
66
|
-
});
|
67
|
-
|
68
|
-
return {
|
69
|
-
log: {
|
70
|
-
version: '1.2',
|
71
|
-
creator: {
|
72
|
-
name: "PhantomJS",
|
73
|
-
version: phantom.version.major + '.' + phantom.version.minor +
|
74
|
-
'.' + phantom.version.patch
|
75
|
-
},
|
76
|
-
pages: [{
|
77
|
-
startedDateTime: startTime.toISOString(),
|
78
|
-
id: address,
|
79
|
-
title: title,
|
80
|
-
pageTimings: {}
|
81
|
-
}],
|
82
|
-
entries: entries
|
83
|
-
}
|
84
|
-
};
|
85
|
-
}
|
86
|
-
|
87
|
-
var page = require('webpage').create(),
|
88
|
-
system = require('system');
|
89
|
-
|
90
|
-
if (system.args.length === 1) {
|
91
|
-
console.log('Usage: netsniff.coffee <some URL>');
|
92
|
-
phantom.exit();
|
93
|
-
} else {
|
94
|
-
|
95
|
-
page.address = system.args[1];
|
96
|
-
page.resources = [];
|
97
|
-
|
98
|
-
page.onLoadStarted = function () {
|
99
|
-
page.startTime = new Date();
|
100
|
-
};
|
101
|
-
|
102
|
-
page.onResourceRequested = function (req) {
|
103
|
-
page.resources[req.id] = {
|
104
|
-
request: req,
|
105
|
-
startReply: null,
|
106
|
-
endReply: null
|
107
|
-
};
|
108
|
-
};
|
109
|
-
|
110
|
-
page.onResourceReceived = function (res) {
|
111
|
-
if (res.stage === 'start') {
|
112
|
-
page.resources[res.id].startReply = res;
|
113
|
-
}
|
114
|
-
if (res.stage === 'end') {
|
115
|
-
page.resources[res.id].endReply = res;
|
116
|
-
}
|
117
|
-
};
|
118
|
-
|
119
|
-
page.open(page.address, function (status) {
|
120
|
-
var har;
|
121
|
-
if (status !== 'success') {
|
122
|
-
console.log('FAIL to load the address');
|
123
|
-
} else {
|
124
|
-
page.title = page.evaluate(function () {
|
125
|
-
return document.title;
|
126
|
-
});
|
127
|
-
har = createHAR(page.address, page.title, page.startTime, page.resources);
|
128
|
-
console.log(JSON.stringify(har, undefined, 4));
|
129
|
-
}
|
130
|
-
phantom.exit();
|
131
|
-
});
|
132
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
helloWorld = () -> console.log phantom.outputEncoding + ": こんにちは、世界!"
|
2
|
-
|
3
|
-
console.log "Using default encoding..."
|
4
|
-
helloWorld()
|
5
|
-
|
6
|
-
console.log "\nUsing other encodings..."
|
7
|
-
for enc in ["euc-jp", "sjis", "utf8", "System"]
|
8
|
-
do (enc) ->
|
9
|
-
phantom.outputEncoding = enc
|
10
|
-
helloWorld()
|
11
|
-
|
12
|
-
phantom.exit()
|
@@ -1,16 +0,0 @@
|
|
1
|
-
function helloWorld() {
|
2
|
-
console.log(phantom.outputEncoding + ": こんにちは、世界!");
|
3
|
-
}
|
4
|
-
|
5
|
-
console.log("Using default encoding...");
|
6
|
-
helloWorld();
|
7
|
-
|
8
|
-
console.log("\nUsing other encodings...");
|
9
|
-
|
10
|
-
var encodings = ["euc-jp", "sjis", "utf8", "System"];
|
11
|
-
for (var i = 0; i < encodings.length; i++) {
|
12
|
-
phantom.outputEncoding = encodings[i];
|
13
|
-
helloWorld();
|
14
|
-
}
|
15
|
-
|
16
|
-
phantom.exit()
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# Read the Phantom webpage '#intro' element text using jQuery and "includeJs"
|
2
|
-
|
3
|
-
page = require('webpage').create()
|
4
|
-
|
5
|
-
page.onConsoleMessage = (msg) -> console.log msg
|
6
|
-
|
7
|
-
page.open "http://www.phantomjs.org", (status) ->
|
8
|
-
if status is "success"
|
9
|
-
page.includeJs "http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", ->
|
10
|
-
page.evaluate ->
|
11
|
-
console.log "$(\"#intro\").text() -> " + $("#intro").text()
|
12
|
-
phantom.exit()
|
13
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
// Read the Phantom webpage '#intro' element text using jQuery and "includeJs"
|
2
|
-
|
3
|
-
var page = require('webpage').create();
|
4
|
-
|
5
|
-
page.onConsoleMessage = function(msg) {
|
6
|
-
console.log(msg);
|
7
|
-
};
|
8
|
-
|
9
|
-
page.open("http://www.phantomjs.org", function(status) {
|
10
|
-
if ( status === "success" ) {
|
11
|
-
page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
|
12
|
-
page.evaluate(function() {
|
13
|
-
console.log("$(\"#intro\").text() -> " + $("#intro").text());
|
14
|
-
});
|
15
|
-
phantom.exit();
|
16
|
-
});
|
17
|
-
}
|
18
|
-
});
|
19
|
-
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# Find pizza in Mountain View using Yelp
|
2
|
-
|
3
|
-
page = require('webpage').create()
|
4
|
-
url = 'http://lite.yelp.com/search?find_desc=pizza&find_loc=94040&find_submit=Search'
|
5
|
-
|
6
|
-
page.open url,
|
7
|
-
(status) ->
|
8
|
-
if status isnt 'success'
|
9
|
-
console.log 'Unable to access network'
|
10
|
-
else
|
11
|
-
results = page.evaluate ->
|
12
|
-
pizza = []
|
13
|
-
list = document.querySelectorAll 'span.address'
|
14
|
-
for item in list
|
15
|
-
pizza.push(item.innerText)
|
16
|
-
return pizza
|
17
|
-
console.log results.join('\n')
|
18
|
-
phantom.exit()
|
@@ -1,20 +0,0 @@
|
|
1
|
-
// Find pizza in Mountain View using Yelp
|
2
|
-
|
3
|
-
var page = require('webpage').create(),
|
4
|
-
url = 'http://lite.yelp.com/search?find_desc=pizza&find_loc=94040&find_submit=Search';
|
5
|
-
|
6
|
-
page.open(url, function (status) {
|
7
|
-
if (status !== 'success') {
|
8
|
-
console.log('Unable to access network');
|
9
|
-
} else {
|
10
|
-
var results = page.evaluate(function() {
|
11
|
-
var list = document.querySelectorAll('span.address'), pizza = [], i;
|
12
|
-
for (i = 0; i < list.length; i++) {
|
13
|
-
pizza.push(list[i].innerText);
|
14
|
-
}
|
15
|
-
return pizza;
|
16
|
-
});
|
17
|
-
console.log(results.join('\n'));
|
18
|
-
}
|
19
|
-
phantom.exit();
|
20
|
-
});
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# Example using HTTP POST operation
|
2
|
-
|
3
|
-
page = require('webpage').create()
|
4
|
-
server = 'http://posttestserver.com/post.php?dump'
|
5
|
-
data = 'universe=expanding&answer=42'
|
6
|
-
|
7
|
-
page.open server, 'post', data, (status) ->
|
8
|
-
if status isnt 'success'
|
9
|
-
console.log 'Unable to post!'
|
10
|
-
else
|
11
|
-
console.log page.content
|
12
|
-
phantom.exit()
|
@@ -1,14 +0,0 @@
|
|
1
|
-
// Example using HTTP POST operation
|
2
|
-
|
3
|
-
var page = require('webpage').create(),
|
4
|
-
server = 'http://posttestserver.com/post.php?dump',
|
5
|
-
data = 'universe=expanding&answer=42';
|
6
|
-
|
7
|
-
page.open(server, 'post', data, function (status) {
|
8
|
-
if (status !== 'success') {
|
9
|
-
console.log('Unable to post!');
|
10
|
-
} else {
|
11
|
-
console.log(page.content);
|
12
|
-
}
|
13
|
-
phantom.exit();
|
14
|
-
});
|