我目前正在使用 phantomjs 生成 HAR 文件。但它有时会挂断,因此我正在尝试使用 Chrome 来完成它。我安装了它,还安装了chrome-har-capturer为我完成工作。
但是当我试图执行
chrome-har-capturer -o out.har https://github.com
这是假话
cannot connect to chrome
error : connect ECONNREFUSED
谁能告诉我我错过了什么...我在 centos(64)VPS 和 chrome 最新稳定版上
最佳答案
根据我的经验,我认为问题是 Chrome 无法正常打开。由于您使用的是 VPS,它没有窗口环境,因此您还需要确保安装了 Xvfb 以提供虚拟视觉缓冲区。您可以使用
yum install xorg-x11-server-Xvfb
然后使用
xvfb-run google-chrome --remote-debugging-port=9222 > /dev/null &
应该在后台启动 google chrome。如果一切正常,那么现在使用命令捕获 har 文件应该没有问题。
要确保 chrome 正在运行,请使用
ps -aux|grep google-chrome
一旦 chrome 正常运行,您就可以使用
chrome-har-capturer -o out.har https://github.com
关于google-chrome - chrome har文件生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32262751/