나는 노드와 PhantomJS 사이에 다양한 브리지를 시도하고 또 다른 브리지를 작성했다. 그것은 phridge에게 전화를 PhantomJS에 기능을 전달하고 노드로 결과를 반환하는 방법을 제공하는 것 :
// node
phantom.run("h1", function (selector, resolve) {
// this code runs inside PhantomJS
phantom.addCookie("cookie_name", "cookie_value", "localhost");
var page = webpage.create();
page.customHeaders = {
Referer: "http://google.com"
};
page.settings = {
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5)"
};
page.open("http://www.google.com", function() {
var text = page.evaluate(function (selector) {
return document.querySelector(selector).innerText;
}, selector);
// resolve the promise and pass 'text' back to node
resolve(text);
});
}).then(function (text) {
// inside node again
console.log("The element contains the following text: "+ text);
});
네, 가능합니다, [Node.js를 함께 Phantom.JS 통합 모듈]가있다 (https : //로 github의를 .com/sgentle/phantomjs-node). 좀 더 구체적인 대답이 필요하면 좀 더 구체적인 질문을 할 필요가 있습니다. :) –