Last active
August 29, 2015 14:06
-
-
Save prabhatkashyap/d782a532d7086ec939a1 to your computer and use it in GitHub Desktop.
CasperJS is an open source navigation scripting & testing utility written in Javascript for the PhantomJS WebKit headless browser and SlimerJS (Gecko)
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 characters
| var casper = require('casper').create({ | |
| verbose: true, | |
| logLevel: 'error', | |
| pageSettings: { | |
| loadImages: false, | |
| loadPlugins: false, | |
| userAgent: 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36' | |
| } | |
| }); | |
| var x = require('casper').selectXPath; | |
| var links = []; | |
| function getLinks() { | |
| var links = document.querySelectorAll('#content li'); | |
| return Array.prototype.map.call(links, function(e) { | |
| return e.getAttribute('p'); | |
| }); | |
| } | |
| casper.start('http://andersonferminiano.com/jqueryscrollpagination/', function() { | |
| this.scrollToBottom(); | |
| }); | |
| casper.wait(10000, function () { | |
| var numTimes = 5, page = 1; | |
| casper.repeat(numTimes, function () { | |
| this.scrollToBottom(); | |
| casper.wait(10000, function () { | |
| }) | |
| }) | |
| page=page+1; | |
| }) | |
| casper.run(function() { | |
| // echo results in some pretty fashion | |
| var html = this.evaluate(function() { | |
| return document; | |
| }); | |
| this.echo(html.all[0].outerHTML).exit(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment