0

Please suggest me, how to remove division. i am wring bellow code for scraping but that is not working for remove division. I have used javascript and jquery to remove the div but its not working on casperjs . SO I want the solution in casperjs to remove html element like div .

casper.then(function () {
        this.wait(10000, function () {
            var elems = [];
            var outputlength = this.getElementsInfo('.context').length;

            for (var i = 0; i < outputlength; i++)
            {
                var as = this.getElementsInfo('#context_' + i + ' .a').length;
                var elems = [];
                var isDelete = false;
                for (var j = 0; j < as; j++)
                {
                    var text = this.fetchText('#b_' + i + '_' + j);
                    x = text.split(" ");

                    if (elems.length == 0) {
                        elems.push(x[0]);
                    } else if (elems.indexOf(text) == -1) {
                        isDelete = true;
                        break;
                    }
                }
                if (casper.exists('#context_' + i + '.notAvailableCell'))
                {
                    isDelete = true;
                }
                if (isDelete) {
                    this.wait(2000, function () {
                        this.evaluate(function () {
                            $('#context_' + i).remove();
                        });
                    });
                }
            }
            this.wait(2000, function () {
                this.capture("screenshot.png");
            });
        });
    });

1 Answers1

0

I have found the solution for remove division dynamically by using jquery with casperjs.

this.evaluate(function (d) {
    $('#context_' + d).remove();
    return d;
}, i);

Now it is working fine for me.