-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathUtils.js
More file actions
36 lines (32 loc) · 707 Bytes
/
Utils.js
File metadata and controls
36 lines (32 loc) · 707 Bytes
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
var https = require('https'),
http = require('http');
module.exports = {
gt_https_req: function(hostname, path, cb) {
var options = {
hostname: hostname,
port: 443,
path: path,
method: 'GET',
rejectUnauthorized: 'false'
};
var req = https.request(options, function(res) {
var body = [];
res.setEncoding('utf8');
res
.on('data', function(chunk) {
body.push(chunk);
})
.on('end', function() {
var $ = cheerio.load(body.join(''));
cb($);
});
});
req.end();
req.on('error', function(e) {
console.log("Error: " + e.message);
console.log( e.stack );
req.end();
});
},
http_req: null
};