phantomjs 卡住, cpu 100%

2016-08-03 18:42:52 +08:00
 anexplore

执行如下命令,发现卡住了,而且一个线程把 cpu 搞到 100%了,除了 kill 有啥方法解决这个问题?

render_multi_url.js 在 examples 包里

bin/phantomjs --debug=true render_multi_url.js "www.tlnews.cn/forum/forumdisplay.php?fid=54573"
4794 次点击
所在节点    程序员
8 条回复
zhouyg
2016-08-03 18:53:15 +08:00
那个 render_multi_url.js 是啥
bdbai
2016-08-03 19:56:53 +08:00
为什么不直接发请求呢
anexplore
2016-08-03 20:02:58 +08:00
我需要保存页面 截图
TaMud
2016-08-04 00:51:01 +08:00
page.onError = function(msg, trace) {
var msgStack = ['ERROR: ' + msg];
console.error(msgStack.join('\n'));
phantom.exit();
};
anexplore
2016-08-04 09:50:33 +08:00
@TaMud 这个不起作用,这儿没有 error 事件,具体请看 https://github.com/ariya/phantomjs/issues/14444
willis
2016-08-04 11:36:37 +08:00
timeout 10 phantomjs --debug=true render_multi_url.js "www.tlnews.cn/forum/forumdisplay.php?fid=54573"
willis
2016-08-04 11:37:11 +08:00
timeout 命令有些发行版要自己装
willis
2016-08-04 11:40:51 +08:00
还有可以用 nice 命令调整 cpu 优先级,要 root

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/296907

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX