为NightmareJS指定SOCKS代理?

xen*_*ndi 11 javascript proxy socks nightmare electron

我能够为NightmareJS设置一个HTTP代理,但是如何指定类型(http/socks5/socks4)?这是我用来设置HTTP代理的代码:

const nightmare = Nightmare({
            show:true,
            switches: {
                'proxy-server': proxyHost + ':' + proxyPort,
                'ignore-certificate-errors': true
            },
            waitTimeout: 400000
        });
Run Code Online (Sandbox Code Playgroud)

小智 12

您可以通过URI方案指定代理的类型: socks5://

const nightmare = Nightmare({
    switches: {
        'proxy-server': 'socks5://' + proxyHost + ':' + proxyPort,
    },
});
Run Code Online (Sandbox Code Playgroud)