Nightmarejs代理

时间:2017-03-30 07:10:18

标签: javascript proxy nightmare

所以,我噩梦是为了生成用户使用页面来获取页面代理的HTTP请求的场景 为此,我使用http-proxy并将其设置如下:

var http = require('http'),
    httpProxy = require('http-proxy');

httpProxy.createProxyServer({target:'http://localhost:9000', auth: 'test:test'}).listen(8000);
http.createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
  res.end();
}).listen(9000);

然后我像这样使用噩梦:

var nightmare = Nightmare({show: true,
        switches : {
            'proxy-server': 'localhost:9000;',
            'ignore-certificate-errors': true,
        }})
nightmare.authentication('test', 'test')
        .goto('http://localhost:4200/login')
        .type('#name', 'test'+user)
        .type('#pwd', 'test'+user)
        .click('#log')
        .wait('body')

但是当我启动它时,噩梦继续代理(所以localhost:9000)并忽略goto(localhost:4200),有人可以帮助我吗?

0 个答案:

没有答案