Commit 42d4b14f 42d4b14f52b538f770fe200db83c4b8b67f688cf by Nicolas Perriault

removed obsolete example.js

1 parent 96fc2436
1 phantom.injectJs('casper.js');
2
3 function q() {
4 document.querySelector('input[name="q"]').setAttribute('value', '%term%');
5 document.querySelector('form[name="f"]').submit();
6 }
7
8 function getLinks() {
9 var links = document.querySelectorAll('h3.r a');
10 return [].map.call(links, function(e) {
11 return e.getAttribute('href');
12 });
13 }
14
15 var links = [];
16 var casper = new phantom.Casper({
17 logLevel: "debug",
18 verbose: true
19 })
20 .start('http://google.fr/')
21 .thenEvaluate(q, {
22 term: 'casper',
23 })
24 .then(function(self) {
25 links = self.evaluate(getLinks);
26 })
27 .thenEvaluate(q, {
28 term: 'homer',
29 })
30 .then(function(self) {
31 links = links.concat(self.evaluate(getLinks));
32 self.log("Click on 1st result link").click('h3.r a');
33 })
34 .then(function(self) {
35 self.debugPage();
36 })
37 .run(function(self) {
38 self.echo(JSON.stringify({
39 result: self.result,
40 links: links
41 }, null, ' '));
42 self.exit();
43 })
44 ;