removed obsolete example.js
Showing
1 changed file
with
0 additions
and
44 deletions
example.js
deleted
100644 → 0
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 | ; |
-
Please register or sign in to post a comment