node-metainspector icon indicating copy to clipboard operation
node-metainspector copied to clipboard

Client not removed completely and interferes with future requests

Open fox-alvarez opened this issue 9 years ago • 4 comments

Good day

I am having a problem

The plugin works fine when the url is entered from another accessible page hits http, url But when he is sent to a page that is not actually there first enters:

client.once("error", function(err) {
        console.log("##  ERR  ##", err);
        //socket.emit("datosWebScraping", err);
        //delete client;
    });

and returning the data:

Object {code: "ENOTFOUND", errno: "ENOTFOUND", syscall: "getaddrinfo"} 

But when I want to re-scrape the page if it exists, it is as if the previous error has affected this new client (or former client has not been deleted) and this causes the following error

TypeError: Object #<EventEmitter> has no method 'title'
    at EventEmitter.<anonymous> (/root/nodejs/proyect/WebScraping.js:15:37)

I was noticing as trying to erase all traces of the client created on each request, but nothing worked for me.

The code in my js file on the server is as follows:

var MetaInspector = require('node-metainspector');
function EscanearWeb(socket, datos_entrada) {

    var client = new MetaInspector(datos_entrada.url, {});
    client.once("fetch", function() {
        var datos_salida = {};
        datos_salida.title = client.title();
        datos_salida.description = client.description();
        datos_salida.image = client.image();
        socket.emit("datosWebScraping", datos_salida);
    });

    client.once("error", function(err) {
        console.log("##  ERR  ##", err);
        socket.emit("datosWebScraping", err);
        //delete client;
    });

    client.fetch();
}

I need that every request will create a new client and can be removed without a trace. I hope you can help me

Greetings

fox-alvarez avatar Sep 09 '14 23:09 fox-alvarez