casper Dom的操作
phantom.casperTest = true; phantom.outputEncoding="utf-8"; var casper = require('casper').create({ // pageSettings: { // loadImages: true, // loadPlugins: false // }, logLevel: "info", verbose: false }); var fs=require('fs'); casper.start('http://js.studio-kingdom.com/javascript/element/get_attribute', function() { }); casper.then(function(){ this.wait(5000, function() { var url= this.evaluate(function() { // return document.querySelector('li[class="nav-header"]').innerHTML; return __utils__.getElementByXPath('//li[@class="nav-header"]').innerText; }); this.echo(url); }); }); //casper.then(function() { //this.capture('baiduSearch.png'); //}); casper.run();