我想让节点进程等待响应

时间:2018-04-20 07:59:19

标签: node.js

我使用噩梦模块制作刮刀。 但是一个网站被搜查了一个带有capcha的机器人

我的解决方案是节点进程将chapcha图像提供给前端。 然后我给出了从前面到现有节点进程的capcha值。

但我有一个问题。 我无法找到节点进程的维护方式。

您是否知道用于维护节点进程的节点模块? 或者有解决方案吗?

这是后端Soruce。

io.on('connection', function(client){
    client.on('event', function(data){});
    client.on('disconnect', function(){});

    client.on('test2', function(value){
        console.log("aaa");
        nightmare
            .goto("http://naver.com")
            .wait(1000)
            .end()
    });

    client.on('test', function(val){

        console.log(nightmare);

        nightmare
            .goto("https://www.amazon.de/")
            .evaluate(() => document.querySelector('body').innerHTML)
            .then(function (html) {
                console.log("wait");
            })
            .catch((error) => {
                console.error(error,'Promise error');
            });

    });
});

这是一个前端来源。

methods: {
      test: function() {
          this.$socket.emit('test');
      },
        test2: function() {
            this.$socket.emit('test2');
        }

0 个答案:

没有答案