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.
Files changed (191) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG +11 -0
  3. data/MIT-LICENSE +21 -0
  4. data/lib/phantomjs.rb +4 -2
  5. data/lib/phantomjs/version.rb +1 -1
  6. data/phantomjs.rb.gemspec +5 -1
  7. metadata +20 -186
  8. data/vendor/phantomjs-1.4.1_OSX/ChangeLog +0 -145
  9. data/vendor/phantomjs-1.4.1_OSX/LICENSE.BSD +0 -22
  10. data/vendor/phantomjs-1.4.1_OSX/README.md +0 -33
  11. data/vendor/phantomjs-1.4.1_OSX/bin/Info.plist +0 -12
  12. data/vendor/phantomjs-1.4.1_OSX/bin/phantomjs +0 -0
  13. data/vendor/phantomjs-1.4.1_OSX/examples/arguments.coffee +0 -6
  14. data/vendor/phantomjs-1.4.1_OSX/examples/arguments.js +0 -8
  15. data/vendor/phantomjs-1.4.1_OSX/examples/colorwheel.coffee +0 -46
  16. data/vendor/phantomjs-1.4.1_OSX/examples/colorwheel.js +0 -51
  17. data/vendor/phantomjs-1.4.1_OSX/examples/countdown.coffee +0 -8
  18. data/vendor/phantomjs-1.4.1_OSX/examples/countdown.js +0 -9
  19. data/vendor/phantomjs-1.4.1_OSX/examples/detectsniff.coffee +0 -40
  20. data/vendor/phantomjs-1.4.1_OSX/examples/detectsniff.js +0 -57
  21. data/vendor/phantomjs-1.4.1_OSX/examples/direction.coffee +0 -29
  22. data/vendor/phantomjs-1.4.1_OSX/examples/direction.js +0 -34
  23. data/vendor/phantomjs-1.4.1_OSX/examples/echoToFile.coffee +0 -19
  24. data/vendor/phantomjs-1.4.1_OSX/examples/echoToFile.js +0 -22
  25. data/vendor/phantomjs-1.4.1_OSX/examples/features.js +0 -30
  26. data/vendor/phantomjs-1.4.1_OSX/examples/fibo.coffee +0 -8
  27. data/vendor/phantomjs-1.4.1_OSX/examples/fibo.js +0 -9
  28. data/vendor/phantomjs-1.4.1_OSX/examples/follow.coffee +0 -54
  29. data/vendor/phantomjs-1.4.1_OSX/examples/follow.js +0 -59
  30. data/vendor/phantomjs-1.4.1_OSX/examples/hello.coffee +0 -2
  31. data/vendor/phantomjs-1.4.1_OSX/examples/hello.js +0 -2
  32. data/vendor/phantomjs-1.4.1_OSX/examples/imagebin.coffee +0 -19
  33. data/vendor/phantomjs-1.4.1_OSX/examples/imagebin.js +0 -22
  34. data/vendor/phantomjs-1.4.1_OSX/examples/injectme.coffee +0 -23
  35. data/vendor/phantomjs-1.4.1_OSX/examples/injectme.js +0 -25
  36. data/vendor/phantomjs-1.4.1_OSX/examples/ipgeocode.coffee +0 -13
  37. data/vendor/phantomjs-1.4.1_OSX/examples/ipgeocode.js +0 -14
  38. data/vendor/phantomjs-1.4.1_OSX/examples/loadspeed.coffee +0 -17
  39. data/vendor/phantomjs-1.4.1_OSX/examples/loadspeed.js +0 -22
  40. data/vendor/phantomjs-1.4.1_OSX/examples/modernizr.js +0 -1116
  41. data/vendor/phantomjs-1.4.1_OSX/examples/movies.coffee +0 -13
  42. data/vendor/phantomjs-1.4.1_OSX/examples/movies.js +0 -14
  43. data/vendor/phantomjs-1.4.1_OSX/examples/netlog.coffee +0 -17
  44. data/vendor/phantomjs-1.4.1_OSX/examples/netlog.js +0 -23
  45. data/vendor/phantomjs-1.4.1_OSX/examples/netsniff.coffee +0 -109
  46. data/vendor/phantomjs-1.4.1_OSX/examples/netsniff.js +0 -131
  47. data/vendor/phantomjs-1.4.1_OSX/examples/outputEncoding.coffee +0 -12
  48. data/vendor/phantomjs-1.4.1_OSX/examples/outputEncoding.js +0 -16
  49. data/vendor/phantomjs-1.4.1_OSX/examples/phantomwebintro.coffee +0 -13
  50. data/vendor/phantomjs-1.4.1_OSX/examples/phantomwebintro.js +0 -19
  51. data/vendor/phantomjs-1.4.1_OSX/examples/pizza.coffee +0 -18
  52. data/vendor/phantomjs-1.4.1_OSX/examples/pizza.js +0 -20
  53. data/vendor/phantomjs-1.4.1_OSX/examples/post.coffee +0 -12
  54. data/vendor/phantomjs-1.4.1_OSX/examples/post.js +0 -14
  55. data/vendor/phantomjs-1.4.1_OSX/examples/rasterize.coffee +0 -22
  56. data/vendor/phantomjs-1.4.1_OSX/examples/rasterize.js +0 -27
  57. data/vendor/phantomjs-1.4.1_OSX/examples/render_multi_url.coffee +0 -48
  58. data/vendor/phantomjs-1.4.1_OSX/examples/render_multi_url.js +0 -60
  59. data/vendor/phantomjs-1.4.1_OSX/examples/run-jasmine.coffee +0 -59
  60. data/vendor/phantomjs-1.4.1_OSX/examples/run-jasmine.js +0 -77
  61. data/vendor/phantomjs-1.4.1_OSX/examples/run-qunit.coffee +0 -62
  62. data/vendor/phantomjs-1.4.1_OSX/examples/run-qunit.js +0 -74
  63. data/vendor/phantomjs-1.4.1_OSX/examples/scandir.coffee +0 -15
  64. data/vendor/phantomjs-1.4.1_OSX/examples/scandir.js +0 -21
  65. data/vendor/phantomjs-1.4.1_OSX/examples/seasonfood.coffee +0 -17
  66. data/vendor/phantomjs-1.4.1_OSX/examples/seasonfood.js +0 -19
  67. data/vendor/phantomjs-1.4.1_OSX/examples/simpleserver.coffee +0 -35
  68. data/vendor/phantomjs-1.4.1_OSX/examples/simpleserver.js +0 -40
  69. data/vendor/phantomjs-1.4.1_OSX/examples/sleepsort.coffee +0 -17
  70. data/vendor/phantomjs-1.4.1_OSX/examples/sleepsort.js +0 -24
  71. data/vendor/phantomjs-1.4.1_OSX/examples/technews.coffee +0 -17
  72. data/vendor/phantomjs-1.4.1_OSX/examples/technews.js +0 -16
  73. data/vendor/phantomjs-1.4.1_OSX/examples/tweets.coffee +0 -30
  74. data/vendor/phantomjs-1.4.1_OSX/examples/tweets.js +0 -36
  75. data/vendor/phantomjs-1.4.1_OSX/examples/unrandomize.coffee +0 -18
  76. data/vendor/phantomjs-1.4.1_OSX/examples/unrandomize.js +0 -24
  77. data/vendor/phantomjs-1.4.1_OSX/examples/useragent.coffee +0 -11
  78. data/vendor/phantomjs-1.4.1_OSX/examples/useragent.js +0 -14
  79. data/vendor/phantomjs-1.4.1_OSX/examples/version.coffee +0 -5
  80. data/vendor/phantomjs-1.4.1_OSX/examples/version.js +0 -5
  81. data/vendor/phantomjs-1.4.1_OSX/examples/waitfor.coffee +0 -48
  82. data/vendor/phantomjs-1.4.1_OSX/examples/waitfor.js +0 -57
  83. data/vendor/phantomjs-1.4.1_OSX/examples/weather.coffee +0 -48
  84. data/vendor/phantomjs-1.4.1_OSX/examples/weather.js +0 -57
  85. data/vendor/phantomjs-1.4.1_OSX/lib/jquery.js +0 -8374
  86. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/ChangeLog +0 -177
  87. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/LICENSE.BSD +0 -22
  88. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/README.md +0 -33
  89. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/bin/Info.plist +0 -12
  90. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/bin/phantomjs +0 -0
  91. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/arguments.coffee +0 -7
  92. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/arguments.js +0 -9
  93. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/colorwheel.coffee +0 -46
  94. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/colorwheel.js +0 -51
  95. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/countdown.coffee +0 -8
  96. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/countdown.js +0 -9
  97. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/detectsniff.coffee +0 -41
  98. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/detectsniff.js +0 -58
  99. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/direction.coffee +0 -30
  100. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/direction.js +0 -35
  101. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.coffee +0 -20
  102. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.js +0 -24
  103. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/features.js +0 -30
  104. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/fibo.coffee +0 -8
  105. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/fibo.js +0 -9
  106. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/follow.coffee +0 -29
  107. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/follow.js +0 -34
  108. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/hello.coffee +0 -2
  109. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/hello.js +0 -2
  110. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/imagebin.coffee +0 -20
  111. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/imagebin.js +0 -23
  112. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.coffee +0 -23
  113. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.js +0 -25
  114. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/ipgeocode.coffee +0 -13
  115. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/ipgeocode.js +0 -14
  116. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/loadspeed.coffee +0 -18
  117. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/loadspeed.js +0 -23
  118. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/modernizr.js +0 -1116
  119. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/movies.coffee +0 -13
  120. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/movies.js +0 -14
  121. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netlog.coffee +0 -18
  122. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netlog.js +0 -25
  123. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netsniff.coffee +0 -110
  124. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netsniff.js +0 -132
  125. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/outputEncoding.coffee +0 -12
  126. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/outputEncoding.js +0 -16
  127. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/phantomwebintro.coffee +0 -13
  128. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/phantomwebintro.js +0 -19
  129. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/pizza.coffee +0 -18
  130. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/pizza.js +0 -20
  131. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/post.coffee +0 -12
  132. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/post.js +0 -14
  133. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/postserver.js +0 -34
  134. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/printenv.js +0 -10
  135. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/printmargins.js +0 -35
  136. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/rasterize.coffee +0 -23
  137. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/rasterize.js +0 -28
  138. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/render_multi_url.coffee +0 -50
  139. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/render_multi_url.js +0 -62
  140. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-jasmine.coffee +0 -61
  141. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-jasmine.js +0 -79
  142. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-qunit.coffee +0 -64
  143. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-qunit.js +0 -76
  144. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/scandir.coffee +0 -16
  145. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/scandir.js +0 -22
  146. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/seasonfood.coffee +0 -17
  147. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/seasonfood.js +0 -19
  148. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/server.js +0 -43
  149. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/serverkeepalive.js +0 -34
  150. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/simpleserver.coffee +0 -38
  151. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/simpleserver.js +0 -42
  152. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/sleepsort.coffee +0 -20
  153. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/sleepsort.js +0 -25
  154. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/technews.coffee +0 -17
  155. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/technews.js +0 -16
  156. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/tweets.coffee +0 -31
  157. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/tweets.js +0 -37
  158. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/unrandomize.coffee +0 -18
  159. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/unrandomize.js +0 -24
  160. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/useragent.coffee +0 -11
  161. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/useragent.js +0 -14
  162. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/version.coffee +0 -5
  163. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/version.js +0 -5
  164. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/waitfor.coffee +0 -48
  165. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/waitfor.js +0 -57
  166. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/weather.coffee +0 -49
  167. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/weather.js +0 -58
  168. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.la +0 -28
  169. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.prl +0 -7
  170. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so +0 -0
  171. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4 +0 -0
  172. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4.8 +0 -0
  173. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4.8.0 +0 -0
  174. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.la +0 -28
  175. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.prl +0 -7
  176. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so +0 -0
  177. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4 +0 -0
  178. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4.8 +0 -0
  179. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4.8.0 +0 -0
  180. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.la +0 -28
  181. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.prl +0 -7
  182. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so +0 -0
  183. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4 +0 -0
  184. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4.8 +0 -0
  185. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4.8.0 +0 -0
  186. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.la +0 -28
  187. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.prl +0 -6
  188. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so +0 -0
  189. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4 +0 -0
  190. data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4.9 +0 -0
  191. 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,17 +0,0 @@
1
- page = require('webpage').create()
2
- address = phantom.args[0]
3
-
4
- if phantom.args.length is 0
5
- console.log 'Usage: netlog.coffee <some URL>'
6
- phantom.exit()
7
- else
8
- page.onResourceRequested = (req) ->
9
- console.log 'requested ' + JSON.stringify(req, undefined, 4)
10
-
11
- page.onResourceReceived = (res) ->
12
- console.log 'received ' + JSON.stringify(res, undefined, 4)
13
-
14
- page.open address, (status) ->
15
- if status isnt 'success'
16
- console.log 'FAIL to load the address'
17
- phantom.exit()
@@ -1,23 +0,0 @@
1
- var page = require('webpage').create(),
2
- address = phantom.args[0];
3
-
4
- if (phantom.args.length === 0) {
5
- console.log('Usage: netlog.js <some URL>');
6
- phantom.exit();
7
- } else {
8
-
9
- page.onResourceRequested = function (req) {
10
- console.log('requested: ' + JSON.stringify(req, undefined, 4));
11
- };
12
-
13
- page.onResourceReceived = function (res) {
14
- console.log('received: ' + JSON.stringify(res, undefined, 4));
15
- };
16
-
17
- page.open(address, function (status) {
18
- if (status !== 'success') {
19
- console.log('FAIL to load the address');
20
- }
21
- phantom.exit();
22
- });
23
- }
@@ -1,109 +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
-
78
- if phantom.args.length is 0
79
- console.log 'Usage: netsniff.js <some URL>'
80
- phantom.exit()
81
- else
82
- page.address = phantom.args[0]
83
- page.resources = []
84
-
85
- page.onLoadStarted = ->
86
- page.startTime = new Date()
87
-
88
- page.onResourceRequested = (req) ->
89
- page.resources[req.id] =
90
- request: req
91
- startReply: null
92
- endReply: null
93
-
94
- page.onResourceReceived = (res) ->
95
- if res.stage is 'start'
96
- page.resources[res.id].startReply = res
97
- if res.stage is 'end'
98
- page.resources[res.id].endReply = res
99
-
100
- page.open page.address, (status) ->
101
- if status isnt 'success'
102
- console.log 'FAIL to load the address'
103
- else
104
- page.title = page.evaluate ->
105
- document.title
106
-
107
- har = createHAR page.address, page.title, page.startTime, page.resources
108
- console.log JSON.stringify har, undefined, 4
109
- phantom.exit()
@@ -1,131 +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
-
89
- if (phantom.args.length === 0) {
90
- console.log('Usage: netsniff.js <some URL>');
91
- phantom.exit();
92
- } else {
93
-
94
- page.address = phantom.args[0];
95
- page.resources = [];
96
-
97
- page.onLoadStarted = function () {
98
- page.startTime = new Date();
99
- };
100
-
101
- page.onResourceRequested = function (req) {
102
- page.resources[req.id] = {
103
- request: req,
104
- startReply: null,
105
- endReply: null
106
- };
107
- };
108
-
109
- page.onResourceReceived = function (res) {
110
- if (res.stage === 'start') {
111
- page.resources[res.id].startReply = res;
112
- }
113
- if (res.stage === 'end') {
114
- page.resources[res.id].endReply = res;
115
- }
116
- };
117
-
118
- page.open(page.address, function (status) {
119
- var har;
120
- if (status !== 'success') {
121
- console.log('FAIL to load the address');
122
- } else {
123
- page.title = page.evaluate(function () {
124
- return document.title;
125
- });
126
- har = createHAR(page.address, page.title, page.startTime, page.resources);
127
- console.log(JSON.stringify(har, undefined, 4));
128
- }
129
- phantom.exit();
130
- });
131
- }
@@ -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
- });