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();

  

posted @ 2017-08-01 16:21  公众号python学习开发  阅读(132)  评论(0编辑  收藏  举报