Tag: phantomjs

PhantomJS在分页间切割/分割单词

我正在使用phantomjs-node API来呈现PDF。 问题是出现在页面末尾附近的单词分成两页,第一页的一半,第二页的另一半。我不明白为什么会发生这种情况。 我能做些什么来解决这个问题? 我已经在phantomjs github上创build了一个没有任何反应的问题 。 直到运行时数据的长度是未知的,所以我不认为在数据行中设置硬分页符是可行的。 你使用哪个版本的PhantomJS? phantomjs-node ^ v2.1.21 哪些步骤将重现该问题? 一个。 创build多页面网站 湾 呈现为pdf 你正在使用哪个操作系统? 窗户10 x64 你使用二进制PhantomJS还是你从源代码编译? phantomjs-node预编译 请在下面提供任何附加信息。

node-canvas在Node中工作,但在PhantomJS中需要时会失败

我有一个PhantomJS应用程序,我想从JS驱动页面(通过page.renderBase64('PNG') )获取一系列截图,然后将这些截图page.renderBase64('PNG')到GIF中。 据我所知,Node中没有办法用纯的base64string来构buildGIF,我真的不想把每一帧写到磁盘上,然后到Node外面用ImageMagick或类似的东西把它们缝在一起这会大大减缓这个过程。 所以我的计划是将base64图像绘制到canvas上,然后将canvas添加到Node GIF生成器。 虽然我可以在节点环境中使用node-canvas ,但是在我的Phantom脚本中包含require('canvas')时,当我启动一个新的Canvas对象时,吐出了缺less依赖关系时常见的错误: Error: Cannot find module './lib/node-canvas/build/Release/canvas' phantomjs://platform/bootstrap.js:299 in require phantomjs://platform/bootstrap.js:263 in require 我想,问题的一部分就是Phantom正在不同的环境中运行Node,而不是所有的依赖都不存在。 但是我不太了解Node和PhantomJS在执行Javascript方面的不同。 我不清楚什么是phantomjs://platform/bootstrap.js是否是我可以扩展的东西。 为了清楚起见,我正在使用Phantom-Node桥,在那里我用var page = require('webpage').create(); 。 然后我使用phantomjs从命令行执行脚本。 TL; DR:从PhantomJS脚本中需要基于C ++的Node模块node-canvas,它会失败,从Node运行时不会失败。 环境如何不同? 为什么一些Node模块工作而其他模块却不工作? 更新:我知道我可以在由Phantom渲染的页面上创build一个<canvas>元素并使用它,但是这需要在页面的沙箱化JS和页面之间来回耗费大量时间脚本本身。

产生的phantomjs过程挂

我试图创build一个节点服务器,产生phantomjs进程来创build屏幕截图。 grab.js脚本在执行时工作正常,我已经确认它写入标准输出。 问题是生成过程简单地挂起的节点代码。 我已经确认phantomjs在路上。 任何人都知道这里可能会发生什么,或者我可能会如何解决这个问题? 下面是渲染页面并将数据写入标准输出的phantomjs代码(grab.js): var page = require('webpage').create(), system = require('system'), fs = require('fs'); var url = system.args[1] || 'google.com'; page.viewportSize = { width: 1024, height: 1200 }; page.open(url, function() { var b64 = page.renderBase64('png'); fs.write('/dev/stdout', b64, 'w'); phantom.exit(); }); 下面是生成幻影进度并打印结果(挂起)的节点代码: var http = require('http'), exec = require('child_process').exec, fs = require('fs'); exec('phantomjs grab.js […]

如何自动testinghtml5媒体元素

我目前使用nodejs,grunt和phantomjs来自动化testing的JavaScript。 但是我最近注意到phantomjs不支持html5媒体元素(video,audio,轨道)。 我想知道有没有人知道解决这个问题的好方法? 还是你跳过使用HTML5媒体元素的testing自动化? 问候,约翰

在屏幕抓取应用程序中使用静止存储凭据的合理安全方法是什么?

借助PhantomJS,CasperJS允许您在应用程序启动时指定要加载的JSON文件。 我有我的凭据存储在这个文件,这是比在源文件中硬编码好一点: var json = require('testfile.json'); var username = json['username']; var mykey = json['mykey']; 我仍然将服务器上的凭据以纯文本forms存储,我希望远离这些凭据。 这个过程将被自动化,所以我不能通过命令行parameter passing凭据,也不会在Windows任务计划程序中存储参数。 什么是安全的方式来存储这些信息呢?

在目录中运行所有'test.html'文件 – mocha-phantomjs

我有一个模块,我使用mocha-phantomjs来testing这个模块。 我创build了package.json文件 { "name" : "demo-test", "scripts": { "test": "npm run test-debug", "test-debug": "mocha-phantomjs ./test/Test1.html" }, "dependencies" : { "mocha" : "1.13.x", "commander" : "1.2.x", "which" : "~1.0.5", "mocha-phantomjs": "3.3.2" }, "devDependencies" : { "chai" : "1.8.x", "coffee-script" : "1.6.x", "requirejs" : "2.1.x", "jquery" : "2.1.0" } } 然后我运行npm install ,然后npm test来运行testing。 它工作正常,并运行test1.html的testing。 现在我想要在testing目录下的所有文件(test1,test2,…)在执行npm test执行。 […]

PhantomJS没有正确地提供JS和CSS文件

我有一个节点服务器运行并监听端口8080.有一个mod_rewrite规则处于活动状态,将Botsredirect到此端口。 RewriteCond %{HTTP_USER_AGENT} (googlebot|adsbot-google|bingbot|msnbot|psbot|gigabot|twitterbot|linkedinbot|yahoo-mmcrawler|pingdom\.com_bot) [NC] RewriteRule ^ http://127.0.0.1:8080%{REQUEST_URI} [P] 节点脚本依赖phantomjs脚本来打开漫游器请求的任何URL并返回内容。 代码取自http://backbonetutorials.com/seo-for-single-page-apps/ 我通过在本地机器上运行phantomjs并使用相同的phantomjs代码直接请求我的网页来testing这一点。 结果与“crawl as google”表示的一样(google网站pipe理员工具),也就是说CSS和JS文件没有被phantomjs正确提供。 CSS文件只包含 <html><head></head><body></body></html> 没有实际的CSS内容。 JS文件有 <html><head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"> 插入任何JS代码之前的最开始。 因此,当谷歌试图抓取和呈现页面布局被打破,JS错误抛出。 任何提示? 谢谢。

在Windows上安装PhantomJS:回滚错误:EPERM,取消链接phantomjs.exe

我尝试在我的Windows机器上安装karam / Jasmine / PhantomJS。 它之前安装在一个不同的项目中。 我有我的代理很好地build立,但它引发了一个奇怪的错误。 npm ERR! error rolling back Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe' npm ERR! error rolling back karma-phantomjs-launcher@0.1.4 { [Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe'] npm ERR! error rolling back errno: 50, npm ERR! error rolling back code: 'EPERM', npm ERR! error rolling back path: 'C:\\xampp\\htdocs\\acme\\node_modules\\karma-phantomjs-launcher\\node_modules\\phantomjs\\lib\\phantom\\phantomjs.exe' } npm ERR! Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe' […]

PhanomJS卡住了 WebPage – updateLoadingProgress:90

我试图使用幻像1.9.8加载一个页面“ https://sliderdevatha.engageclick.com/optus/agent.html?chatId=someChatUniqueId ” 这里是我的ssl.js console.log('Loading a web page'); var page = require('webpage').create(); var url = "https://sliderdevatha.engageclick.com/optus/agent.html?chatId=someChatUniqueId"; page.open(url, function (status) { console.log('========================'); console.log(status); console.log('========================'); //Page is loaded! phantom.exit(); }); 这是我试图运行的命令 phantomjs –ignore-ssl-errors=yes –web-security=false –debug=true –ssl-protocol=any ssl.js 这里是输出,它被卡住了 WebPage – updateLoadingProgress:90 我究竟做错了什么? 有没有一种方法可以读取一半或任何内容加载到现在? 2015-01-27T14:53:27 [DEBUG] CookieJar – Created but will not store cookies (use option '–cookies-file=<filename>' to […]

如何在AWS Lambda中使用phantomjs 2.0

我从https://github.com/bprodoehl/phantomjs/releases/下载phantomjs二进制文件,在我的本地主机上testing很好。 打包并创buildaws lambda函数 exports.handler = function (event, context) { var path = require("path"); var Process = require("child_process"); Process.exec(path.join(__dirname,"./bin/phantomjs")+" –version", function (err, data) { if (err) { console.log(err.message); context.fail(err.stack); } else { context.succeed(data); } }) } 但是在lambda中testing时,总是得到 {"errorMessage":"Error: Command failed: /bin/sh: /var/task/bin/phantomjs: Permission denied at ChildProcess.exithandler (child_process.js:658:15) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:766:16) at Socket.<anonymous> (child_process.js:979:11) […]