1
我试图从下面的函数返回一个值,像这样。如何从扩展casperjs函数返回值?
html = casper.get_HTML(myselector);
我得到的所有回报是“undefined”(return_html)。但是,'html'变量设置正确。全部功能正常工作。这只是问题的返回值。
你怎么做到的?
casper.get_HTML = function(myselector) {
var return_html;
casper.waitForSelector(myselector,
function() {
var html = casper.getHTML(myselector, false);
return_html = html; //got the html
},
function() { // Do this on timeout
return_html = null;
},
10000 // wait 10 secs
);
return return_html;
};
谢谢。作品不错! – 2014-09-06 09:34:52