Last active
August 29, 2015 13:56
-
-
Save t-ashula/9171317 to your computer and use it in GitHub Desktop.
node-phantom infinite loop issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="euc-jp"/> | |
</head> | |
<body> | |
<script src="utf8.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "test", | |
"version": "0.0.1", | |
"private": true, | |
"dependencies": { | |
"node-phantom": "*" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.write('☃'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have this issue too.
Did you find a way to workaround it?