@kpostal10/

casper-nodejs

Nodejs

No description

fork
loading
Files
  • index.js
  • src
  • casper-node.js
  • package-lock.json
  • package.json
  • README.md
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
  01-load-page

  Load a 
*/

var casper_nodejs = require('./casper-node.js');

var url = "http://google.com";

var casper = casper_nodejs.create(url, {
  casper: {
    'logLevel' : 'debug',
    'verbose': true
  }
});

// casper.then variants:
// ------------------------------------------------------------------------------------------
// casper.then(fn_in_current_context, null)
// casper.then(fn_in_casperjs_context, fn_in_current_context)
// ------------------------------------------------------------------------------------------

casper.then(function executed_in_this_context() {
  console.log("page loaded");
});

casper.then(function executed_in_this_context() {
  console.log("and");
});

casper.then(function executed_in_this_context() {
  console.log("a");
});

casper.then(function executed_in_this_context() {
  console.log("test");
});

casper.then(function executed_in_casperjs_context() {

  return {'test' : 45};
}, function executed_after_in_this_context(ret) {
  console.log('[REPONSE 1] ' + JSON.stringify(ret.test) );
});

// Start casper

casper.run();

// Exit in 6 seconds

setTimeout(function() {
  console.log('exit :)');
  casper.exit();
}, 6000);



node v10.16.0