phantomjs

Phantomjs works but is very slow

て烟熏妆下的殇ゞ 提交于 2019-12-03 05:55:17
问题 I am trying to take a screenshot of a webpage with PhantomJS. Specifically, I am using the example of capturing espn.com from this example. My code looks like this: var page = new WebPage(); page.open('http://www.espn.com', function (status) { page.render('fb.png'); phantom.exit(); }); I then go to my PhantomJS directory with either my terminal or command prompt and run: phantomjs shotty.js Everything runs great, however it takes 6-8 seconds to complete the output image. Is that normal? Is

Using the 'webpage' Phantom module in node.js

帅比萌擦擦* 提交于 2019-12-03 05:54:43
问题 I am trying to wrap a PhantomJS script in a node.js process. The phantom script grabs a url from the arguments provided on the command line and outputs a pdf (much similar to the rasterize.js example included with the pahntom install). The phantom script I have works fine, it's just my employer wants a node script if possible. No problem, I can use the node-phantom node module to wrap it. But now I've hit a stumbling block, my phantom script has: var page = require('webpage').create(); So,

Is there a way to run unit test for a WebGL webapp in a headless browser

ε祈祈猫儿з 提交于 2019-12-03 05:42:32
Is there a way to run unit test for a WebGL (GLGE) webapp in a headless browser? I'd like to run the tests on a jenkins server, so the tests must run on a headless (phantom.js) brower. Anybody already tried that? Cheers gman The Chromium project runs automated webgl and other gpu tests on normal machines that are unattended but they have a shared monitor and are vnc connected so we can remotely service them. You can also run Chromium with osmesa. See https://stackoverflow.com/a/39060739/128511 来源: https://stackoverflow.com/questions/13763325/is-there-a-way-to-run-unit-test-for-a-webgl-webapp

PhantomJS / Javascript: write to file instead of to console

旧街凉风 提交于 2019-12-03 05:41:44
问题 From PhantomJS, how do I write to a log instead of to the console? In the examples https://github.com/ariya/phantomjs/wiki/Examples, it always (in the ones I have looked at) says something like: console.log('some stuff I wrote'); This is not so useful. 回答1: The following can write contents to the file directly by phantomjs: var fs = require('fs'); try { fs.write("/home/username/sampleFileName.txt", "Message to be written to the file", 'w'); } catch(e) { console.log(e); } phantom.exit(); The

How to set window size using phantomjs and selenium webdriver in python

試著忘記壹切 提交于 2019-12-03 05:18:17
I'm trying to get a full sized browser screenshot with phantomjs driven by python webdriver . right now my screenshot is measured at 927 x 870, I'd like to reset it. I have tried: driver.manage().window().setSize(new Dimension(1400,1000)) based on this source , but this is giving syntax errors. How can I do this? Because that's Java. Python's documentation is here . There's a method called set_window_size , which is defined here : driver.set_window_size(1400,1000) Further reading: How to get window size, resize or maximize window using Selenium WebDriver For Java, the Dimension import has to

Navigating / scraping hashbang links with javascript (phantomjs)

瘦欲@ 提交于 2019-12-03 05:16:11
问题 I'm trying to download the HTML of a website that is almost entirely generated by JavaScript. So, I need to simulate browser access and have been playing around with PhantomJS. Problem is, the site uses hashbang URLs and I can't seem to get PhantomJS to process the hashbang -- it just keeps calling up the homepage. The site is http://www.regulations.gov. The default takes you to #!home. I've tried using the following code (from here) to try and process different hashbangs. if (phantom.state

phantomjs exit() doesn't terminate the process

六月ゝ 毕业季﹏ 提交于 2019-12-03 05:07:04
问题 I've been using phantom.js on Windows 7 for quite some time now (I think v1.4.0 was the first version I used) and everything was always fine. But for some reason the process isn't properly terminated any longer when calling phantom.exit() and I absolutely don't know why. The problem started to occur in v1.7.0, from one day to another. Everything once worked fine in 1.7.0 but then it did no more. Even after upgrading to 1.8.0 and now 1.9.0 it still doesnt work. The console just hangs. I can't

html转换为pdf

梦想与她 提交于 2019-12-03 05:03:14
将html转换为pdf的工具有两个:phantomjs和wkhtmltopdf,下面分别对两个工具进行介绍。 phantomjs phantomjs不仅仅只是一个html2pdf的工具,这个是一个Headless WebKit(现在chrome也支持这种模式运行了),可以用来写前端测试等一系列的功能(可惜的是该项目已经停止维护了,项目地址: https://github.com/ariya/phantomjs )。回到主题,phantomjs使用简单,可以自己编写相关测输出脚本,运行的cmd:phantomjs.exe rasterize.js http://www.oschina.net/ test.pdf "A4",可以参考该项目的官方网址: https://phantomjs.org/ ,比较可惜的是,该项目在window下生成的pdf是很完美的,但是linux下生成的pdf文件就比较糟糕了,主要是dpi惹的祸,直到项目停止维护,该问题都没有解决。为了解决linux下可以完美渲染,在网上查找了很多资料,最终发现phantomjs的pdf生成功能依赖于另一个项目wkhtmltopdf。 wkhtmltopdf 该项目是一个将html转化为pdf的项目,项目地址: https://github.com/wkhtmltopdf/wkhtmltopdf ,该工具生成pdf非常简单

VCRProxy: Record PhantomJS ajax calls with VCR inside Capybara

☆樱花仙子☆ 提交于 2019-12-03 04:54:15
问题 I already did some research in this field, but didn't find any solution. I have a site, where asynchron ajax calls are made to facebook (using JSONP). I'm recording all my HTTP requests on the Ruby side with VCR, so I thought it would be cool, to use this feature for AJAX calls as well. So I played a little bit around, and came up with a proxy attempt. I'm using PhantomJS as a headless browser and poltergeist for the integration inside Capybara. Poltergeist is now configured to use a proxy

Unable to load Atom ''find_element"

∥☆過路亽.° 提交于 2019-12-03 04:43:56
问题 I have recently installed PhantomJS and encountered this error on my first run: from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.PhantomJS() driver.get("http://www.google.com") driver.find_element_by_id('some_element').send_keys('something' + Keys.RETURN) This code works with Firefox webdriver but does not work with PhantomJS. I get the following error: Traceback (most recent call last): File "<PATHTOFILE>", line 20, in <module> driver.find