S
S
Shakir Yakubov2020-06-05 17:59:12
JavaScript
Shakir Yakubov, 2020-06-05 17:59:12

Why does the site still give an error when connecting via injectJS to the CapserJs jquery library?

Included jQuery in CasperJs. But in the end, the site still throws an error ReferenceError: Can't find variable: $

var start = performance.now();
var casper = require('casper').create();

casper.start();
casper.open('https://www.mirsud.spb.ru/cases/detail/15/?id=2-802%2F2020-15');

casper.then(function() {
  var jquery = this.page.injectJs('jquery.js');
  console.log('Выполняю, результат: ' + jquery);
});

casper.then(function() {
  casper.waitForSelector('b.table-title', function () {
      var html = this.evaluate(function () {
          return document.querySelector('div[ng-if="case.judge"]').querySelector('span.list').innerHTML;
      });
      var str = html.trim();
      console.log(str);
      var end = performance.now();
      var delta = end - start;
      console.log(delta);
  });
});

casper.then(function(){
  $.ajax({
        url: 'parser.php',
        type: 'POST',
        data: {param: 'massiv'},
        dataType: 'json'
    });
});

casper.run();

/*success: function (json) {
    if (json) $('body').html(json);
}*/
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question