我正在使用无头浏览器构建一个Crawler但是现在我想停泊我的应用程序我已经在我的docker镜像中安装了chrome但是在运行脚本时它会给我一个错误。
StartChrome.js
const chromeLauncher = require('chrome-launcher');
chromeLauncher.launch({
port: 9222,
chromeFlags: ['--headless','--proxy-server=54.171.181.204:8888','--disable-web-security','--disable-gpu']
}).then(chrome => {
console.log(`Chrome debugging port running on ${chrome.port}`);
});
ERR
(node:415) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: connect ECONNREFUSED 127.0.0.1:9222
(node:415) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
当我在命令行中运行时,它会抛出一个像这样的错误
Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
Trace/breakpoint trap
答案 0 :(得分:1)
您可以尝试使用像 yukinying / chrome-headless-browser 这样的Docker Image:https://hub.docker.com/r/yukinying/chrome-headless-browser/
来自说明:
此docker镜像包含Linux Dev通道Chromium (https://www.chromium.org/getting-involved/dev-channel),与 必需的依赖项和无头运行的命令行参数 模式。