Tag: phantomjs

如何用npm安装PhantomJS v2

我试图安装PhantomJS v2.0.0使用npm和尝试了几个方法后,我还没有find一个工作的解决scheme… 在NPM上,最新版本是1.9.16 ,所以我在我的package.json尝试了以下内容: "phantomjs": "https://github.com/ariya/phantomjs/archive/2.0.0.tar.gz" 这给了我一个错误,因为在github仓库中没有这个版本的package.json 。 "phantomjs": "2.0.0" 这告诉我没有可用的这个号码的版本。 我在这里错过了什么?

phantomjs可以使用node.js吗?

我想在我的node.js脚本中使用phantomjs。 有一个phantomjs节点库..但不幸的是作者使用这个怪异的咖啡脚本代码来解释他在做什么: phantom = require 'phantom' phantom.create (ph) -> ph.createPage (page) -> page.open "http://www.google.com", (status) -> console.log "opened google? ", status page.evaluate (-> document.title), (result) -> console.log 'Page title is ' + result ph.exit() 现在如果我直接用javascript来使用phantomjs,它会看起来像这样 : var page = require('webpage').create(); page.open(url, function (status) { var title = page.evaluate(function () { return document.title; }); console.log('Page title […]

如何在不同的casperjs进程之间保持cookie

这是一个关于如何将cookies从一个casperjs页面保存到另一个页面的问题。 所以基本上我有一个nodejs文件,产生casperjs作为一个工人来做某些任务..一个是login,一旦login,我将cookie存储在一个文件中。 当我产卵下一个casper工人..我希望它使用cookie,而不必再次login..这两个方法失败 : 第一:当我产卵的工人capserjs我添加–cookies文件=。/ cookiefilename即var child = spawn('casperjs',['scrape.js','–cookies-file=./'+cookieFileName]); 第二:在casperjs工作人员文件..我让它读取和设置从一个文件的cookie即 var casper = require('casper').create(); var cookieFileName = 'monsterCookie.txt'; // grab cookies from file var fs = require('fs'); var utils = require('utils'); var cookies = fs.read(cookieFileName); casper.page.setCookies(cookies); casper.start('domain/page.html', function() { //FAIL! cookies aren't used here this.debugHTML(); }); casper.run(); 笔记: 前面已经提到 , start从页面中删除cookies? 如果是的话,我该如何防止呢? 我知道会话在相同的phantomjs页面对象(参见https://gist.github.com/abbood/5347252 )中保持不变,在同一个casperjs页面对象中也是如此(请参阅https://gist.github.com/ abbood […]

Nodejssubprocess:从已经初始化的进程写入stdin

我正尝试使用节点的child_process产生一个外部进程phantomjs ,然后在初始化之后将信息发送到该进程,这可能吗? 我有以下代码: var spawn = require('child_process').spawn, child = spawn('phantomjs'); child.stdin.setEncoding = 'utf-8'; child.stdout.pipe(process.stdout); child.stdin.write("console.log('Hello from PhantomJS')"); 但是我在stdout上唯一得到的是phantomjs控制台的初始提示。 phantomjs> 所以似乎child.stdin.write没有任何效果。 我不知道我可以发送额外的信息phantomjs最初的产卵。 提前致谢。

PhantomJS从string创build页面

有没有可能从string创build一个页面? 例: html = '<html><body>blah blah blah</body></html>' page.open(html, function(status) { // do something }); 我已经尝试了上面没有运气…. 另外,我认为值得一提的是我正在使用nodejs和phantomjs-node(https://github.com/sgentle/phantomjs-node) 谢谢!