浙江省高等学校教师教育理论培训

微信搜索“教师资格证岗前培训”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

From your comments,

Id guess you have 2 options

  1. Try to find a phantomjs node module - https://github.com/sgentle/phantomjs-node
  2. Run phantomjs as a child process inside node - http://nodejs.org/api/child_process.html

Hope this helps

Edit:

It seems the child process is suggested by phantomjs as a way of interacting with node see faq -http://code.google.com/p/phantomjs/wiki/FAQ

Edit:

Example Phantomjs script for getting the pages HTML markup:

var page = require('webpage').create();  
page
.open('http://www.google.com', function (status) {
   
if (status !== 'success') {
        console
.log('Unable to access network');
   
} else {
       
var p = page.evaluate(function () {
           
return document.getElementsByTagName('html')[0].innerHTML
       
});
        console
.log(p);
   
}
    phantom
.exit();
});

posted on 2012-05-11 08:27  lexus  阅读(359)  评论(0编辑  收藏  举报