-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
30 lines (24 loc) · 998 Bytes
/
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
var path = require('path')
var childProcess = require('child_process')
var phantomjs = require('phantomjs-prebuilt')
var binPath = phantomjs.path
var childArgs = [
path.join(__dirname, 'script.js'), process.env.EMAIL, process.env.PASSWORD, '--ssl-protocol=any'
]
var express = require('express')
var app = express()
app.get('/', function(req, res) {
var result = '';
var child = childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
console.log('stdout ', stdout);
console.log('stderr ', stderr);
console.log('err', err);
res.send({data : result});
})
// use event hooks to provide a callback to execute when data are available:
child.stdout.on('data', function(data) {
result += data.toString().replace(/([^.@\s]+)(\.[^.@\s]+)*@([^.@\s]+\.)+([^.@\s]+)/,"");
console.log(data.toString().replace(/([^.@\s]+)(\.[^.@\s]+)*@([^.@\s]+\.)+([^.@\s]+)/,""));
});
})
app.listen(process.env.PORT || 3000)