Last active
August 29, 2015 14:02
-
-
Save n1k0/26d66212caae3a45f9ce to your computer and use it in GitHub Desktop.
This file contains 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(); | |
var arr1 = [], arr2 = [], arr3 = []; | |
casper.start("http://foo.bar/", function() { | |
arr1.push("plop1"); | |
}); | |
casper.thenOpen("http://bar.foo/", function() { | |
arr2.push("plop2"); | |
}); | |
casper.thenClick("#trololo", function() { | |
arr3.push("plop3"); | |
}); | |
casper.run(function() { | |
require("utils").dump([arr1[0], arr2[0], arr3[0]]); | |
this.exit(); | |
}); |
This file contains 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(); | |
var data = {arr1: [], arr2: [], arr3: []}; | |
casper.start().then(function() { | |
data.arr1.push("plop1"); | |
}); | |
casper.then(function() { | |
data.arr2.push("plop2"); | |
}); | |
casper.then(function() { | |
data.arr3.push("plop3"); | |
}); | |
casper.run(function() { | |
var extractFirstItems = Object.keys(data).map(function(key) { | |
return data[key][0]; | |
}); | |
require("utils").dump(extractFirstItems); | |
this.exit(); | |
}); | |
/* | |
$ casperjs 2_alternatively.js | |
[ | |
"plop1", | |
"plop2", | |
"plop3" | |
] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mon but n'est pas d'avoir juste les élément 0 du tableau mais tout les élément de même niveau. En gros je veux construire pour chaque ligne la valeur correspondant à [x] dans chacun des différents tableaux. Exemple :
si dans x j'ai : [1,2,3] dans y : [4,5,6] et dans z : [7,8,9] je veux en sortie dans généré par le run qqchose comme :
1,4,7
2,5,9
3,6,9
Pour l'instant dans mon code j'ai :
casper.run(function() {
global = [links,names,titles]; //ici je rempli mon tableau global avec mes trois tableaux)
//là je voudrais un dump ou un echo de ce tableau de la forme expliquée avant