Last active
August 5, 2016 04:58
Revisions
-
n1k0 renamed this gist
Dec 28, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # A CasperJS link checker A simple [CasperJS](http://casperjs.org/) script to periodically check for a link and process accordingly. -
n1k0 revised this gist
Dec 28, 2012 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # A CasperJS link checker daemon A simple [CasperJS](http://casperjs.org/) script to periodically check for a link and process accordingly. ```js -
n1k0 renamed this gist
Dec 28, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
n1k0 revised this gist
Dec 28, 2012 . 1 changed file with 33 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,36 @@ A simple [CasperJS](http://casperjs.org/) script to periodically check for a link and process accordingly. ```js /*jshint strict:false*/ /*global CasperError console phantom require*/ var casper = require('casper').create({ logLevel: "debug", verbose: true }), interval = 1000 * 60, // 1 minute url = 'http://google.com/'; // URL to check casper.checkLink = function checkLink() { this.echo('Setting up check steps...'); this.open(url).then(function() { if (this.exists('#selector-to-your-link')) { this.echo('link was found, clicking'); this.thenClick('#selector-to-your-link').then(function() { // add stuff to be done // ... then exit this.echo('Done.').exit(); }); } else { this.warn('Link not found, scheduling another attempt'); this.wait(interval); } }); this.run(this.checkLink); }; casper.start().checkLink(); ``` Sample output: ``` -
n1k0 revised this gist
Dec 28, 2012 . 2 changed files with 61 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ Sample output: ``` $ casperjs waiter.js [info] [phantom] Starting... Setting up check steps... [debug] [phantom] opening url: http://google.com/, HTTP GET [debug] [phantom] Navigation requested: url=http://google.com/, type=Other, lock=true, isMainFrame=true [info] [phantom] Running suite: 1 step [debug] [phantom] Navigation requested: url=http://www.google.com/, type=Other, lock=true, isMainFrame=true [debug] [phantom] Navigation requested: url=http://www.google.fr/, type=Other, lock=true, isMainFrame=true [debug] [phantom] url changed to "http://www.google.fr/" [debug] [phantom] Successfully injected Casper client-side utilities [info] [phantom] Step 1/1 http://www.google.fr/ (HTTP 301) [warning] [phantom] Link not found, scheduling another attempt ⚠ Link not found, scheduling another attempt [info] [phantom] Step 1/1: done in 1265ms. [info] [phantom] Step 2/2 http://www.google.fr/ (HTTP 301) [info] [phantom] Step 2/2: done in 1364ms. [info] [phantom] wait() finished waiting for 10000ms. [info] [phantom] Done 2 steps in 11387ms Setting up check steps... [debug] [phantom] opening url: http://google.com/, HTTP GET [debug] [phantom] Navigation requested: url=http://google.com/, type=Other, lock=true, isMainFrame=true [info] [phantom] Running suite: 3 steps [debug] [phantom] Navigation requested: url=http://www.google.com/, type=Other, lock=true, isMainFrame=true [debug] [phantom] Navigation requested: url=http://www.google.fr/, type=Other, lock=true, isMainFrame=true [debug] [phantom] url changed to "http://www.google.fr/" [debug] [phantom] Successfully injected Casper client-side utilities [info] [phantom] Step 3/3 http://www.google.fr/ (HTTP 301) [warning] [phantom] Link not found, scheduling another attempt ⚠ Link not found, scheduling another attempt [info] [phantom] Step 3/3: done in 11896ms. [info] [phantom] Step 4/4 http://www.google.fr/ (HTTP 301) [info] [phantom] Step 4/4: done in 11992ms. [info] [phantom] wait() finished waiting for 10000ms. [info] [phantom] Done 4 steps in 22015ms Setting up check steps... [debug] [phantom] opening url: http://google.com/, HTTP GET [debug] [phantom] Navigation requested: url=http://google.com/, type=Other, lock=true, isMainFrame=true [info] [phantom] Running suite: 5 steps [debug] [phantom] Navigation requested: url=http://www.google.com/, type=Other, lock=true, isMainFrame=true [debug] [phantom] Navigation requested: url=http://www.google.fr/, type=Other, lock=true, isMainFrame=true [debug] [phantom] url changed to "http://www.google.fr/" [debug] [phantom] Successfully injected Casper client-side utilities [info] [phantom] Step 5/5 http://www.google.fr/ (HTTP 301) [warning] [phantom] Link not found, scheduling another attempt ⚠ Link not found, scheduling another attempt [info] [phantom] Step 5/5: done in 22525ms. [info] [phantom] Step 6/6 http://www.google.fr/ (HTTP 301) [info] [phantom] Step 6/6: done in 22622ms. ^C ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,12 +4,12 @@ var casper = require('casper').create({ logLevel: "debug", verbose: true }), interval = 1000 * 60, // 1 minute url = 'http://google.com/'; // URL to check casper.checkLink = function checkLink() { this.echo('Setting up check steps...'); this.open(url).then(function() { if (this.exists('#selector-to-your-link')) { this.echo('link was found, clicking'); this.thenClick('#selector-to-your-link').then(function() { @@ -18,13 +18,11 @@ function checkLink() { this.echo('Done.').exit(); }); } else { this.warn('Link not found, scheduling another attempt'); this.wait(interval); } }); this.run(this.checkLink); }; casper.start().checkLink(); -
n1k0 revised this gist
Dec 28, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ function checkLink() { } }); this.run(checkLink); } casper.start().then(function() { this.echo('Daemon started'); -
n1k0 revised this gist
Dec 28, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ var casper = require('casper').create({ interval = 1000 * 60, // 1 minute url = 'http://google.com/'; function checkLink() { this.echo('Setting up check steps...'); this.thenOpen(url, function() { if (this.exists('#selector-to-your-link')) { -
n1k0 revised this gist
Dec 28, 2012 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,22 +8,20 @@ var casper = require('casper').create({ url = 'http://google.com/'; var checkLink = function checkLink() { this.echo('Setting up check steps...'); this.thenOpen(url, function() { if (this.exists('#selector-to-your-link')) { this.echo('link was found, clicking'); this.thenClick('#selector-to-your-link').then(function() { // add stuff to be done // ... then exit this.echo('Done.').exit(); }); } else { this.echo('Link not found, scheduling another attempt'); this.wait(interval); } }); this.run(checkLink); }; -
n1k0 revised this gist
Dec 28, 2012 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,6 @@ var casper = require('casper').create({ var checkLink = function checkLink() { this.echo('Setting up check...'); this.thenOpen(url, function() { var found = this.exists('#selector-to-your-link'); this.echo(found ? 'link was found' : 'link not found'); if (found) { -
n1k0 revised this gist
Dec 28, 2012 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,24 +5,22 @@ var casper = require('casper').create({ verbose: true }), interval = 1000 * 60, // 1 minute url = 'http://google.com/'; var checkLink = function checkLink() { this.echo('Setting up check...'); this.thenOpen(url, function() { this.echo(this.getCurrentUrl()); var found = this.exists('#selector-to-your-link'); this.echo(found ? 'link was found' : 'link not found'); if (found) { this.thenClick('#selector-to-your-link').then(function() { // add stuff to be done // ... then exit this.echo('Done.').exit(); }); } else { this.echo('Scheduling another attempt'); this.wait(interval); } }); -
n1k0 revised this gist
Dec 27, 2012 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,6 @@ var checkLink = function checkLink() { } }); this.echo('Check steps added'); this.run(checkLink); }; -
n1k0 revised this gist
Dec 27, 2012 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ var casper = require('casper').create({ url = 'http://google.com/'; var checkLink = function checkLink() { this.echo('Setting up check...'); this.thenOpen(url, function() { this.echo(this.getCurrentUrl()); found = this.exists('#selector-to-your-link'); @@ -19,16 +19,18 @@ var checkLink = function checkLink() { if (found) { this.thenClick('#selector-to-your-link').then(function() { // add stuff to be done // ... then exit this.echo('Done.').exit(); }); } else { this.wait(interval); } }); this.echo('Check steps added'); this.echo(this.steps.length); this.run(checkLink); }; casper.start().then(function() { this.echo('Daemon started'); }).run(checkLink); -
n1k0 revised this gist
Dec 27, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ var casper = require('casper').create({ logLevel: "debug", verbose: true }), interval = 1000 * 60, // 1 minute found = false, url = 'http://google.com/'; @@ -21,7 +21,7 @@ var checkLink = function checkLink() { // add stuff to be done }); } else { this.wait(interval); } }); this.echo('checkLink() end'); -
n1k0 created this gist
Dec 27, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ /*jshint strict:false*/ /*global CasperError console phantom require*/ var casper = require('casper').create({ logLevel: "debug", verbose: true }), interval = 1000 * 60 * 1, found = false, url = 'http://google.com/'; var checkLink = function checkLink() { this.echo('checkLink() called'); this.thenOpen(url, function() { this.echo(this.getCurrentUrl()); found = this.exists('#selector-to-your-link'); this.echo(found ? 'link was found' : 'link not found'); }); this.then(function() { if (found) { this.thenClick('#selector-to-your-link').then(function() { // add stuff to be done }); } else { this.wait(interval); // 5 more minutes } }); this.echo('checkLink() end'); this.echo(this.steps.length); this.run(checkLink); }; casper.start().then(function() { this.echo('then'); }).run(checkLink);