Skip to content
Browse files

Merge pull request #154 from detro/master

Updated examples that use the 'webpage' module
  • Loading branch information...
2 parents e960279 + e0e5535 commit 4bd0ad233124e7f1bd5860385f15820fa5276ac0 @ariya committed Sep 14, 2011
View
2 examples/colorwheel.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
page.viewportSize = { width: 400, height : 400 }
page.content = '<html><body><canvas id="surface"></canvas></body></html>'
View
2 examples/colorwheel.js
@@ -1,4 +1,4 @@
-var page = new WebPage;
+var page = require('webpage').create();
page.viewportSize = { width: 400, height : 400 };
page.content = '<html><body><canvas id="surface"></canvas></body></html>';
page.evaluate(function() {
View
2 examples/direction.coffee
@@ -1,6 +1,6 @@
# Get driving direction using Google Directions API.
-page = new WebPage()
+page = require('webpage').create()
if phantom.args.length < 2
console.log 'Usage: direction.js origin destination'
View
2 examples/direction.js
@@ -1,6 +1,6 @@
// Get driving direction using Google Directions API.
-var page = new WebPage(),
+var page = require('webpage').create(),
origin, dest, steps;
if (phantom.args.length < 2) {
View
2 examples/follow.coffee
@@ -30,7 +30,7 @@ users= [
]
follow = (user, callback) ->
- page = new WebPage()
+ page = require('webpage').create()
page.open 'http://mobile.twitter.com/' + user, (status) ->
if status is 'fail'
console.log user + ': ?'
View
2 examples/follow.js
@@ -28,7 +28,7 @@ var users = ['sencha',
'whereisthysting'];
function follow(user, callback) {
- var page = new WebPage();
+ var page = require('webpage').create();
page.open('http://mobile.twitter.com/' + user, function (status) {
if (status === 'fail') {
console.log(user + ': ?');
View
2 examples/imagebin.coffee
@@ -1,6 +1,6 @@
# Upload an image to imagebin.org
-page = new WebPage()
+page = require('webpage').create()
if phantom.args.length isnt 1
console.log 'Usage: imagebin.coffee filename'
View
3 examples/imagebin.js
@@ -1,6 +1,7 @@
// Upload an image to imagebin.org
-var page = new WebPage(), fname;
+var page = require('webpage').create(),
+ fname;
if (phantom.args.length !== 1) {
console.log('Usage: imagebin.js filename');
View
2 examples/injectme.coffee
@@ -1,7 +1,7 @@
# Use 'page.injectJs()' to load the script itself in the Page context
if phantom?
- page = new WebPage()
+ page = require('webpage').create()
# Route "console.log()" calls from within the Page context to the main
# Phantom context (i.e. current "this")
View
2 examples/injectme.js
@@ -1,7 +1,7 @@
// Use 'page.injectJs()' to load the script itself in the Page context
if ( typeof(phantom) !== "undefined" ) {
- var page = new WebPage();
+ var page = require('webpage').create();
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
View
2 examples/loadspeed.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
if phantom.args.length is 0
console.log 'Usage: loadspeed.js <some URL>'
View
2 examples/loadspeed.js
@@ -1,4 +1,4 @@
-var page = new WebPage(),
+var page = require('webpage').create(),
t, address;
if (phantom.args.length === 0) {
View
2 examples/netlog.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
address = phantom.args[0]
if phantom.args.length is 0
View
2 examples/netlog.js
@@ -1,4 +1,4 @@
-var page = new WebPage(),
+var page = require('webpage').create(),
address = phantom.args[0];
if (phantom.args.length === 0) {
View
2 examples/netsniff.coffee
@@ -73,7 +73,7 @@ createHAR = (address, title, startTime, resources) ->
]
entries: entries
-page = new WebPage()
+page = require('webpage').create()
if phantom.args.length is 0
console.log 'Usage: netsniff.js <some URL>'
View
2 examples/netsniff.js
@@ -84,7 +84,7 @@ function createHAR(address, title, startTime, resources)
};
}
-var page = new WebPage();
+var page = require('webpage').create();
if (phantom.args.length === 0) {
console.log('Usage: netsniff.js <some URL>');
View
2 examples/phantomwebintro.coffee
@@ -1,6 +1,6 @@
# Read the Phantom webpage '#intro' element text using jQuery and "includeJs"
-page = new WebPage()
+page = require('webpage').create()
page.onConsoleMessage = (msg) -> console.log msg
View
2 examples/phantomwebintro.js
@@ -1,6 +1,6 @@
// Read the Phantom webpage '#intro' element text using jQuery and "includeJs"
-var page = new WebPage();
+var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
View
2 examples/pizza.coffee
@@ -1,6 +1,6 @@
# Find pizza in Mountain View using Yelp
-page = new WebPage()
+page = require('webpage').create()
url = 'http://lite.yelp.com/search?find_desc=pizza&find_loc=94040&find_submit=Search'
page.open url,
View
2 examples/pizza.js
@@ -1,6 +1,6 @@
// Find pizza in Mountain View using Yelp
-var page = new WebPage(),
+var page = require('webpage').create(),
url = 'http://lite.yelp.com/search?find_desc=pizza&find_loc=94040&find_submit=Search';
page.open(url, function (status) {
View
2 examples/post.coffee
@@ -1,6 +1,6 @@
# Example using HTTP POST operation
-page = new WebPage()
+page = require('webpage').create()
server = 'http://posttestserver.com/post.php?dump'
data = 'universe=expanding&answer=42'
View
2 examples/post.js
@@ -1,6 +1,6 @@
// Example using HTTP POST operation
-var page = new WebPage(),
+var page = require('webpage').create(),
server = 'http://posttestserver.com/post.php?dump',
data = 'universe=expanding&answer=42';
View
2 examples/rasterize.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
if phantom.args.length < 2 or phantom.args.length > 3
console.log 'Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat]'
View
2 examples/rasterize.js
@@ -1,4 +1,4 @@
-var page = new WebPage(),
+var page = require('webpage').create(),
address, output, size;
if (phantom.args.length < 2 || phantom.args.length > 3) {
View
2 examples/render_multi_url.coffee
@@ -11,7 +11,7 @@ Array.prototype.forEach = (action) ->
# @param file File to render to
# @param callback Callback function
renderUrlToFile = (url, file, callback) ->
- page = new WebPage()
+ page = require('webpage').create()
page.viewportSize = { width: 800, height : 600 }
page.settings.userAgent = 'Phantom.js bot'
View
2 examples/render_multi_url.js
@@ -16,7 +16,7 @@ Array.prototype.forEach = function (action) {
* @param callback Callback function
*/
function renderUrlToFile(url, file, callback) {
- var page = new WebPage();
+ var page = require('webpage').create();
page.viewportSize = { width: 800, height : 600 };
page.settings.userAgent = "Phantom.js bot";
View
2 examples/run-jasmine.coffee
@@ -33,7 +33,7 @@ if phantom.args.length isnt 1
console.log 'Usage: run-jasmine.coffee URL'
phantom.exit()
-page = new WebPage()
+page = require('webpage').create()
# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = (msg) ->
View
2 examples/run-jasmine.js
@@ -39,7 +39,7 @@ if (phantom.args.length === 0 || phantom.args.length > 2) {
phantom.exit();
}
-var page = new WebPage();
+var page = require('webpage').create();
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
View
2 examples/run-qunit.coffee
@@ -33,7 +33,7 @@ if phantom.args.length isnt 1
console.log 'Usage: run-qunit.coffee URL'
phantom.exit(1)
-page = new WebPage()
+page = require('webpage').create()
# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = (msg) ->
View
2 examples/run-qunit.js
@@ -39,7 +39,7 @@ if (phantom.args.length === 0 || phantom.args.length > 2) {
phantom.exit(1);
}
-var page = new WebPage();
+var page = require('webpage').create();
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
View
2 examples/technews.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
page.viewportSize = { width: 320, height: 480 }
View
2 examples/technews.js
@@ -1,4 +1,4 @@
-var page = new WebPage();
+var page = require('webpage').create();
page.viewportSize = { width: 320, height: 480 };
page.open('http://news.google.com/news/i/section?&topic=t', function (status) {
if (status !== 'success') {
View
2 examples/tweets.coffee
@@ -1,6 +1,6 @@
# Get twitter status for given account (or for the default one, "sencha")
-page = new WebPage()
+page = require('webpage').create()
twitterId = 'sencha' #< default value
# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
View
2 examples/tweets.js
@@ -1,6 +1,6 @@
// Get twitter status for given account (or for the default one, "sencha")
-var page = new WebPage(),
+var page = require('webpage').create(),
twitterId = "sencha"; //< default value
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
View
2 examples/unrandomize.coffee
@@ -1,7 +1,7 @@
# Modify global object at the page initialization.
# In this example, effectively Math.random() always returns 0.42.
-page = new WebPage()
+page = require('webpage').create()
page.onInitialized = ->
page.evaluate ->
Math.random = ->
View
2 examples/unrandomize.js
@@ -1,7 +1,7 @@
// Modify global object at the page initialization.
// In this example, effectively Math.random() always returns 0.42.
-var page = new WebPage();
+var page = require('webpage').create();
page.onInitialized = function () {
page.evaluate(function () {
View
2 examples/useragent.coffee
@@ -1,4 +1,4 @@
-page = new WebPage()
+page = require('webpage').create()
console.log 'The default user agent is ' + page.settings.userAgent
View
2 examples/useragent.js
@@ -1,4 +1,4 @@
-var page = new WebPage();
+var page = require('webpage').create();
console.log('The default user agent is ' + page.settings.userAgent);
page.settings.userAgent = 'SpecialAgent';
page.open('http://www.httpuseragent.org', function (status) {
View
2 examples/waitfor.coffee
@@ -30,7 +30,7 @@ waitFor = (testFx, onReady, timeOutMillis=3000) ->
interval = setInterval f, 250 #< repeat check every 250ms
-page = new WebPage()
+page = require('webpage').create()
# Open Twitter on 'sencha' profile and, onPageLoad, do...
page.open 'http://twitter.com/#!/sencha', (status) ->
View
2 examples/waitfor.js
@@ -34,7 +34,7 @@ function waitFor(testFx, onReady, timeOutMillis) {
};
-var page = new WebPage();
+var page = require('webpage').create();
// Open Twitter on 'sencha' profile and, onPageLoad, do...
page.open("http://twitter.com/#!/sencha", function (status) {
View
2 examples/weather.coffee
@@ -1,6 +1,6 @@
# Get weather info for given address (or for the default one, "Mountain View")
-page = new WebPage()
+page = require('webpage').create()
address = 'Mountain View' #< default value
# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
View
2 examples/weather.js
@@ -1,6 +1,6 @@
// Get weather info for given address (or for the default one, "Mountain View")
-var page = new WebPage(),
+var page = require('webpage').create(),
address = "Mountain View"; //< default value
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")

0 comments on commit 4bd0ad2

Please sign in to comment.
Something went wrong with that request. Please try again.