Skip to content

Instantly share code, notes, and snippets.

@t-ashula
Last active August 29, 2015 13:56
Show Gist options
  • Save t-ashula/9171317 to your computer and use it in GitHub Desktop.
Save t-ashula/9171317 to your computer and use it in GitHub Desktop.
node-phantom infinite loop issue
<!doctype html>
<html>
<head>
<meta charset="euc-jp"/>
</head>
<body>
<script src="utf8.js"></script>
</body>
</html>
{
"name": "test",
"version": "0.0.1",
"private": true,
"dependencies": {
"node-phantom": "*"
}
}
var http = require('http'),
url = require('url'),
fs = require('fs'),
port = 9000;
http.createServer(function(req, res) {
var path = url.parse(req.url).pathname,
name = ( path !== '/utf8.js' ) ? 'index.html' : 'utf8.js';
console.log('req=>' + name);
fs.readFile(name, function(err, file) {
res.writeHead(200);
res.write(file);
res.end();
});
}).listen(port);
var phantom = require('node-phantom'),
url = 'http://localhost:9000/';
console.log('get=>' + url);
phantom.create(function (err, ph) {
ph.createPage(function (err, page) {
page.open(url, function () {
console.log('onOpen');
page.evaluate(function () {
var q = document.body.innerHTML;
return q; //encodeURIComponent(q);
}, function (err, r) {
console.log('onOpen.evaluate=>', r);
ph.exit();
});
});
});
});
document.write('☃');
@crwang
Copy link

crwang commented Feb 26, 2014

I have this issue too.

Did you find a way to workaround it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment