Skip to content

@n1k0 /casperjs-link-checker.md
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A link checker using CasperJS
/*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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.