Tag: phantomjs

Node.js集群模块不释放http.Server.close()上的套接字/端口

在Node.js脚本中,我试图打开一些端口/套接字,然后再closures它们。 使用Node.js集群模块时遇到麻烦。 它似乎没有以不使用群集模块时相同的代码相同的方式closures端口。 例如,下面的代码创build5个http.Server,每个都在它自己的端口上,然后closures除最后一个(第五个)之外的所有其他端口。 'use strict'; var http = require('http'); function goGoGadget(i) { console.log('var i = ', i); var httpServer = http.createServer(); var nextPort = 4000 + i; console.log('about to listen on port', nextPort); httpServer.listen(nextPort); if (i < 5) { httpServer.on('listening', function() { console.log('closing port:', nextPort); httpServer.close(function() { console.log('closed server on port:', nextPort); }); }); […]

uncss错误:C.UTF-8:不是有效的语言标记

嗨我想使用UNCSS第一次从CSS中删除不使用的样式,我得到以下错误: Fontconfig警告:忽略C.UTF-8:不是有效的语言标记 /home/ubuntu/.nvm/v0.10.35/lib/node_modules/uncss/node_modules/bluebird/js/main/async.js:43 fn = function(){throw arg; }; ^错误:Fontconfig警告:忽略C.UTF-8:不是有效的语言标记 at Socket.onStderr (/home/ubuntu/.nvm/v0.10.35/lib/node_modules/uncss/node_modules/phridge/lib/spawn.js:79:28) at Socket.emit (events.js:117:20) at Socket.<anonymous> (_stream_readable.js:765:14) at Socket.emit (events.js:92:17) at emitReadable_ (_stream_readable.js:427:10) at emitReadable (_stream_readable.js:423:5) at readableAddChunk (_stream_readable.js:166:9) at Socket.Readable.push (_stream_readable.js:128:10) at Pipe.onread (net.js:529:21) 我甚至尝试使用Gulp,我一直在寻找一个解决scheme,我不理解输出来解决它。 任何帮助解决这个将不胜感激。 -j

从幻影模块访问原始“page.content”

我正在使用phantom模块与Node.js而不是phantomjs运行时。 如何访问page.content ? 下面的例子不起作用。 var phantom = require('phantom') phantom.create(function (ph) { ph.createPage(function (page) { page.open('http://www.google.com', function (status) { console.log(status) // -> success console.log(page.content) // -> undefined console.log(page.getContent()) // -> undefined ph.exit() }) }) })

有没有办法用CasperJS取得新的文物的仪表板截图?

我尝试从新的文物洞察仪表板捕捉一些图像,但是它不起作用。 该脚本几个星期前工作,但现在,我只是在顶部有一个橙色边框的空白图像(如果JavaScript未启用)。 有我的脚本: http : //pastebin.com/aiBiWXqK 它适用于login页面,但对于其他两个捕获,它显示一个空的页面。 我在.sh文件中像这样运行这个脚本。 PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs /usr/local/bin/casperjs –cookie-file=$(pwd)/tv-cookies.txt $(pwd)/capture.js –ssl-protocol=any –ignore-ssl-errors=true 我试图casper.wait(fun, 300000) ,以确保它将完全加载。 我试图casper.waitForSelector('.dashboard-widgets', fn)来检查select器是否被创build,但它不会工作。 我知道仪表板是用Angular创build的,但我试图捕获用Angular制作的其他网站,没关系。 有谁知道如何做到这一点? 或者使用任何build议或其他包来做到这一点?

使用jsreport与其他语言(不是英文)

我需要生成PDF报告,但问题是我不能用波斯语言渲染,简单的例子: var http = require('http'); var jsreport = require('jsreport'); http.createServer(function(req, res) { jsreport.render({ template: { content: "<h2>سلام</h2>",// means "hello" in persian engine: 'jsrender', recipe: 'phantom-pdf' } }) .then(function(out) { out.stream.pipe(res); }).catch(function(e) { res.end(e.message); }); }).listen(3031, '127.0.0.1'); 生成的PDF包含错误和不可读的任何想法? 感谢您的任何build议。

当通过npm安装phantomjs时,获取“'节点'不被识别为内部或外部命令”

我一直在使用NPM来处理一个大项目来pipe理我的依赖关系。 在过去,我已经把它构build得很好,但是团队做了一些最近的更新,这些更新已经更新了依赖关系,并且我需要重build以确保我拥有了一切最新的东西。 当我在主目录上运行'npm install'的时候,它似乎很好,直到它试图安装phantomjs@1.9.19,在这一点上,我得到以下几点: phantomjs@1.9.19安装c:\ Users \ me \ Perforce \ drice_vir_ui \ node_modules \ phantomjs 节点install.js “节点”不被识别为内部或外部命令, 可操作程序或batch file。 npm ERR! Windows_NT 6.1.7601 npm ERR! argv“C:\ Program Files \ nodejs \ node.exe”“C:\ Users \ me \ AppData \ Roaming \ npm \ node_modules \ npm \ bin \ npm-cli.js”“install”“phantomjs” npm ERR! 节点v5.0.0 npm ERR! […]

PhantomJS从Windows上的节点

我已经使用Node, Electron Boilerplate和phantom编写了一个Electron应用程序。 在我的linux机器上,它对我来说工作得非常好,我把源代码拷贝到了Windows 10上,并且运行了npm start ,一切顺利。 但是,当我尝试使用npm run release构build样板模块的应用程序时,情况npm run release得不那么顺利。 我可以安装并打开应用程序,但是当我点击激活幻像模块的button时,窗户全白,没有任何反应。 我能用开发工具logging一些错误。 首先,我有: C:\…\dist\win-unpacked\resources\app.asar\node_modules\phantom\lib\phantom.js:361 Uncaught (in promise) Error: Error reading from stdin: Error: write EPIPE(…) 我对类似的问题进行了一些研究,也就是在这里 ,在我看来,问题是用npm模块幻像启动subprocessPhantomJS。 最初,我使用的是我在C#中编写的WPF应用程序来启动这个过程,而且工作得很好。 这使我相信,幻影模块是罪魁祸首。 所以我试着换了nma幻影模块换骑士 ,但得到了类似的结果: Unhandled rejection HeadlessError: Phantom immediately exited with: 4294967295 at ChildProcess.immediateExit (C:\…\dist\win-unpacked\resources\app.asar\node_modules\node-horseman\node_modules\node-phantom-simple\node-phantom-simple.js:153:23) at ChildProcess.g (events.js:286:16) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at Process.ChildProcess._handle.onexit […]

Node + Promise + Phantom.JS – 奇怪的错误

我使用Node和npm幻影制作了很多网页的截图。 为了节省CPU,我为每个进程使用一个Phantom实例。 在这种情况下,我打开一个页面,渲染它,closures它并继续。 除了当我开始另一个进程时,这个工作真的很棒。 在这种情况下,我得到这个错误,当一个过程完成时: UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝ID:2):错误:undefined不是一个对象(评估'target [command.params [0]]') 幻影实例: function initPhantom(todos) { phantom.create(['–ignore-ssl-errors=no'], {logLevel: 'error'}) .then(function (instance) { var processId = instance.process.pid; console.log("===================> instance: ", processId); phInstance = instance; webshot(0, todos); }); } 通过URL循环: function webshot(id, shots) { phInstance.createPage().then(function (_page) { sitepage = _page; sitepage.property('viewportSize', {width: 1024, height: 768}); WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 […]

如何发布Node.js中的事件PhantomJS包装从页面到节点?

我从包装库中的这个例子开始。 const instance = await phantom.create(); const page = await instance.createPage(); 要发布从Node.js到PhantomJS的动作 – 包括发射一个事件 – 我可以这样做: await page.evaluate(function() { // Code } 但是相反呢。 我想在nodeJS的页面上监听一个事件。 我写了这个承诺,等待一个事件: class PageEventPromise extends Promise { constructor(page, event) { super(function(resolve, reject) { let callback = function() { let args = []; args.push.apply(args, arguments); page.off(event, callback); resolve(args); } page.on(event, callback); }); } […]

Heroku上的PhantomJSpath

我有一个在Heroku上运行的节点应用程序。 我在python中使用selenium来抓取一个网站,并在我需要的时候从我的节点app调用python脚本。 我在我的Mac上安装PhantomJS,当我在本地运行应用程序(节点index.js)时,一切正常。 path_to_phantom = '/Users/govind/Desktop/phantomjs-2.1.1- macosx/bin/phantomjs' browser = webdriver.PhantomJS(executable_path = path_to_phantom) 然而,Heroku似乎没有任何工作。 我也将PhantomJS buildpack添加到我的节点应用程序,但它只是不会调用python脚本。 我认为这个问题是通往PhantomJS buildpack的path。 我应该添加什么path? 还是有我在这里失踪的其他方面?