Node.js casperjs中的waitforSelector函数
你好,我是Casper和node的新手 我正在尝试运行一个代码,该代码可以从站点抓取数据 但是WaitForselector函数工作不正常 我的代码是Node.js casperjs中的waitforSelector函数,node.js,phantomjs,casperjs,Node.js,Phantomjs,Casperjs,你好,我是Casper和node的新手 我正在尝试运行一个代码,该代码可以从站点抓取数据 但是WaitForselector函数工作不正常 我的代码是 casper.waitForSelector('.searchAutoSuggstn', function() { this.echo('Search auto suggestion.'); // this line is printing my console var data = this.evaluate(functio
casper.waitForSelector('.searchAutoSuggstn', function() {
this.echo('Search auto suggestion.'); // this line is printing my console
var data = this.evaluate(function() {
var suggestions = [];
this.echo('Search auto suggestion data.'); //But this line is not printing my console
var element = $('.searchAutoSuggstn .suggestionsList_menu').find('.topProdhead_left').prevAll().filter(function() {
this.echo('omnitrack');
return $(this).data("omnitrack") ;
});
有人能告诉我主要问题是什么吗?您不能在casper.evaluate()中调用casper方法,例如casper.echo(),因为evaluate在浏览器的上下文中执行代码 您可以在浏览器中使用console.log输出到javascript控制台,然后使用钩子捕获该控制台
casper.on("remote.messsage", function(msg){
// Do something
});
您不能在casper.evaluate()中调用casper方法,例如casper.echo(),因为evaluate在浏览器的上下文中执行代码 您可以在浏览器中使用console.log输出到javascript控制台,然后使用钩子捕获该控制台
casper.on("remote.messsage", function(msg){
// Do something
});
可能的重复可能的重复