Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var casper = require("casper").create();
- var url = casper.cli.get(0);
- var casper = require('casper').create({
- verbose: true,
- logLevel: "debug",
- webSecurityEnabled: false
- });
- casper.on('remote.message', function(msg) {
- this.echo(msg);
- })
- function getLinksFromIframes( callback ) {
- var links = [];
- var iframes = this.evaluate( function() {
- var iframes = [];
- [].forEach.call(document.querySelectorAll("iframe"), function(iframe, i) { iframes.push( i ); });
- return iframes;
- });
- iframes.forEach( function( index ) {
- this.withFrame(index, function() {
- links = links.concat( this.getElementsAttribute( 'a', 'href' ) );
- console.log("works: " + links);
- });
- });
- this.then(function(){
- callback.call(this, links);
- });
- }
- casper.start(url, function () {
- getLinksFromIframes.call(this, function(links){
- thelinks = links;
- console.log("Links: " + thelinks);
- });
- })
- .then(function(){
- console.log("Links later: " + thelinks);
- })
- .run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement