-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06_leitor-cookie.js
45 lines (36 loc) · 1.02 KB
/
06_leitor-cookie.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
// Instanciando o objeto da API Webpage em uma linha
var page = require('webpage').create();
//Objeto da API System
var system = require('system');
url = system.args[1];
//Argumento passado
if (typeof url != null){
//Abre URL
page.open(url, function(status) {
if (status === 'success') {
//Lê o cookie
phantom.cookies.forEach(function(cookie) {
//Imprime cada chave e valor
for (var key in cookie) {
if (key == "domain"){
console.log(' ');
console.log('[Domínio '+cookie[key]+']');
}else{
console.log('Chave: ' + key + ' - Valor: ' + cookie[key]);
}
}
});
phantom.exit(0);
}
});
page.onError = function(msg, trace) {
var msgStack = ['Erro: ' + msg];
if (trace && trace.length) {
msgStack.push('Local do erro:');
trace.forEach(function(t) {
msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function + '")' : ''));
});
}
// console.error(msgStack.join('\n'));
};
}