PhantomJS - libraryPath 属性
此属性具有路径,由 page.inectJs 方法使用。
语法
其语法如下 −
var wpage = require('webpage').create(); wpage.libraryPath = 'filepath';
示例
查看以下示例 −
var webPage = require('webpage'); var page = webPage.create(); page.open('http://www.tutorialspoint.com/jquery', function(status) { if (status === "success") { page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js ', function() { if (page.injectJs('do.js')) { var title = page.evaluate(function() { // returnTitle 是从我们的 do.js 文件加载的一个函数 - 见下文 return returnTitle(); }); console.log(title); phantom.exit(); } }); } }); window.returnTitle = function() { return document.title; };
上述程序生成以下输出。
Jquery Tutorial
phantomjs_webpage_module_properties.html