0
在許多許多鏈接,他們sugest加載jquery爲了做在頁面dom刮。後跟的常見模式是:Phantom.js:本地使用,npm安裝,jquery
var page = require('webpage').create();
var url = 'http://example.com';
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open(url, function (status) {
if(status==='success') {
page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', function() {
//Do stuff there
phantom.exit();
});
} else {
phantom.exit(1);
}
});
但有時這將是迄今爲止網絡wize健全有通過NPM安裝在本地的jQuery:
npm install jquery
但是我怎麼包括本地安裝jQuery?