-
Notifications
You must be signed in to change notification settings - Fork 18
/
loadjs.go
65 lines (61 loc) · 1.6 KB
/
loadjs.go
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
61
62
63
64
65
package phantomgo
/*
* GET method
* system.args[0] == JSfile.js
* system.args[1] == url
* system.args[2] == cookie
* system.args[3] == pageEncode
* system.args[4] == userAgent
*/
const getJs string = `
var system = require('system');
var page = require('webpage').create();
var url = system.args[1];
var cookie = system.args[2];
var pageEncode = system.args[3];
var userAgent = system.args[4];
page.onResourceRequested = function(requestData, request) {
request.setHeader('Cookie', cookie)
};
phantom.outputEncoding=pageEncode;
page.settings.userAgent = userAgent;
page.open(url, function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
console.log(page.content);
}
phantom.exit();
});
`
/*
* POST method
* system.args[0] == JSfile.js
* system.args[1] == url
* system.args[2] == cookie
* system.args[3] == pageEncode
* system.args[4] == userAgent
* system.args[5] == postdata
*/
const postJs string = `
var system = require('system');
var page = require('webpage').create();
var url = system.args[1];
var cookie = system.args[2];
var pageEncode = system.args[3];
var userAgent = system.args[4];
var postdata = system.args[5];
page.onResourceRequested = function(requestData, request) {
request.setHeader('Cookie', cookie)
};
phantom.outputEncoding=pageEncode;
page.settings.userAgent = userAgent;
page.open(url, 'post', postdata, function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
console.log(page.content);
}
phantom.exit();
});
`