标签: phantomjs

Heroku Buildpack Multi - 未检测到Cedar支持的应用程序

我试图在Heroku的工作进程中使用PhantomJS和NodeJS,但是当我切换到buildpack-multi时,Heroku在我推送时给了我这个:

-----> Fetching custom git buildpack... done
 !     Heroku push rejected, no Cedar-supported app detected
Run Code Online (Sandbox Code Playgroud)

这是我的.buildpack:

http://github.com/heroku/heroku-buildpack-nodejs.git
http://github.com/stomita/heroku-buildpack-phantomjs.git
Run Code Online (Sandbox Code Playgroud)

我的根目录中也有一个package.json.

heroku node.js phantomjs

2
推荐指数
1
解决办法
1067
查看次数

使用PhantomJS使用图像渲染HTML

我正在尝试使用PhantomJS(版本1.9.7)从HTML文本创建PDF.我写了一个非常简单的脚本(错误回调等更复杂)

phantom.onError = function(msg, trace) {
    var msgStack = ['PHANTOM ERROR: ' + msg];
    if (trace && trace.length) {
        msgStack.push('TRACE:');
        trace.forEach(function(t) {
            msgStack.push(' -> ' + (t.file || t.sourceURL) + ': ' + t.line + (t.function ? ' (in function ' + t.function + ')' : ''));
        });
    }
    system.stdout.write(msgStack.join('\n'));
    phantom.exit(1);
};

var page = require('webpage').create();
page.viewportSize = { width: 800, height: 600 };
page.paperSize = { format: 'A4', orientation: 'portrait', margin: '1cm' };
page.onResourceRequested = function(requestData, networkRequest) {
    console.log('Request …
Run Code Online (Sandbox Code Playgroud)

phantomjs

2
推荐指数
1
解决办法
8772
查看次数

获取casperjs中的输入值

嗨,我想知道如何使用casperjs获取输入值

这是我的html元素

<input type="hidden" name="key" value="newkey">
Run Code Online (Sandbox Code Playgroud)

这是我尝试过的:

    view            = 'users/registered';

    casper.test.begin("Activating account", 5, function register(test){
        casper.start(webroot + view, function(){

        }).then(function(){
            this.echo("Retrieving data from hidden input key", "COMMENT");

            activationKey = this.evaluate(function() {
                return __utils__.getFieldValue('key');
            });

        }).then(function(){
            this.echo("Activating account with the key \"" + activationKey + "\"", "COMMENT");
            window.location = webroot + activationKey;
        });

        casper.run(function() {
            this.echo('Account activated successfully', 'SUCCESS').exit();
            test.done();
        });
    });

casper.viewport(page.width, page.height);
Run Code Online (Sandbox Code Playgroud)

在这种情况下返回 null

我也尝试过:

activationKey = __utils__.getFieldValue('key');
Run Code Online (Sandbox Code Playgroud)

但是给我这个错误:

FAIL ReferenceError: Can't find variable: __utils__
Run Code Online (Sandbox Code Playgroud)

javascript testing phantomjs casperjs

2
推荐指数
2
解决办法
7252
查看次数

CasperJS 无法设置 window.navigator 对象

尝试使用 CasperJS 抓取网页。网页会检查浏览器是否为 IE 6/7。

使用 casperjs 传递 userAgent 似乎不满足其条件。UserAgent 通过:Mozilla/4.0(兼容;MSIE 6.0;Windows NT 5.1) 以下是页面进行的检查以确定浏览器

agt = navigator.userAgent.toLowerCase();
browserType = navigator.appName;

if( ((browserType.indexOf("xplorer") != -1) 
    && (agt.indexOf("msie 6.") != -1))
    ||  ((browserType.indexOf("xplorer") != -1) 
    && (agt.indexOf("msie 7.") != -1)) )
{

}
else
{
    alert("This "+ browserType + " Version is not supported by this application. Please use Internet Explorer  6.x or Internet Explorer 7.x.");
    window.close();
}
Run Code Online (Sandbox Code Playgroud)

以下是来自 casperjs 的调试信息。

[info] [remote] [alert] 此应用程序不支持此 Netscape 版本。请使用 Internet Explorer 6.x 或 …

javascript headless-browser phantomjs casperjs

2
推荐指数
1
解决办法
795
查看次数

模块版本与无头浏览器和桌面节点不匹配

当我尝试使用带有桌面Node shell的无头浏览器时,我收到了"模块版本不匹配错误".我用nw.js和atom-shell尝试过Zombiejs和Phantomjs; 在两种情况下,只要无头浏览器进入播放状态,应用程序就会因模块不匹配错误而崩溃.

这是Phantomjs和atom-shell的错误:

Uncaught Exception:
Error: Module version mismatch. Expected 41, got 14.
    at Error (native)
    at Object.module.(anonymous function) (ATOM_SHELL_ASAR.js:118:20)
    at Object.module.(anonymous function) [as .node] (ATOM_SHELL_ASAR.js:118:20)
    at Module.load (module.js:370:32)
    at Function.Module._load (module.js:325:12)
    at Module.require (module.js:380:17)
    at require (module.js:399:17)
    at bindings (/Users/Ajay/Projects/atom-shell/node_modules/phantom/node_modules/dnode/node_modules/weak/node_modules/bindings/bindings.js:76:44)
    at Object.<anonymous> (/Users/Ajay/Projects/atom-shell/node_modules/phantom/node_modules/dnode/node_modules/weak/lib/weak.js:7:35)
    at Module._compile (module.js:475:26)
Run Code Online (Sandbox Code Playgroud)

知道导致错误的原因是什么吗?

node.js zombie.js phantomjs nw.js electron

2
推荐指数
1
解决办法
4433
查看次数

在一个脚本中使用多个page.open

我的目标是打开许多页面(延迟很短)并将我的数据保存到文件中.

但我的代码不起作用.

var gamesList = [url1,url2,url3];
//gamesList is getting from a file

var urls = [];
var useragent = [];
useragent.push('Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14');
useragent.push('Opera/9.80 (X11; Linux x86_64; U; fr) Presto/2.9.168 Version/11.50');

var page = require('webpage').create();
page.settings.userAgent = useragent[Math.floor(Math.random() * useragent.length)];
console.log('Loading a web page');


function handle_page(url){
    page.open(url,function(){
        //...
        var html= page.evaluate(function(){
            // ...do stuff...
            page.injectJs('jquery.min.js');
            return $('body').html();
        });
        //save to file
        var file = fs.open('new_test.txt', "w");
        file.write(html + '\n');
        file.close();    

        console.log(html);

        setTimeout(next_page,1000);
    });
}

function next_page(urls){
    var …
Run Code Online (Sandbox Code Playgroud)

javascript phantomjs

2
推荐指数
1
解决办法
3356
查看次数

将PhantomJS二进制文件添加到maven项目的更好方法是什么?

我尝试使用phantomjs-maven-plugin来安装phantomjs二进制文件.我想在Tomcat7服务器上运行我的测试,这就是我需要自动配置二进制文件的原因.

这是我的pom.xml

<properties>
    <ghostdriver.version>1.2.0</ghostdriver.version>
    <phantomjs.version>1.9.7</phantomjs.version>
    <phantomjs-maven-plugin.version>0.7</phantomjs-maven-plugin.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.47.1</version>
    </dependency>

    <dependency>
        <groupId>com.github.detro</groupId>
        <artifactId>phantomjsdriver</artifactId>
        <version>${ghostdriver.version}</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" -->
        <artifactId>jersey-container-servlet</artifactId>
        <version>2.21</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>2.21</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>2.21</version>
    </dependency>
</dependencies>

<build>
    <sourceDirectory>src</sourceDirectory>

    <plugins>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <warSourceDirectory>WebContent</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>

        <plugin>
            <groupId>com.github.klieber</groupId>
            <artifactId>phantomjs-maven-plugin</artifactId>
            <version>${phantomjs-maven-plugin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>install</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <version>1.9.7</version>
            </configuration> …
Run Code Online (Sandbox Code Playgroud)

java maven phantomjs selenium-webdriver phantomjs-maven-plugin

2
推荐指数
1
解决办法
1万
查看次数

在 osx 上使用 python 打开/关闭 wifi

可能是因为我的 ISP 提供商的原因,有时当我不在时,互联网会出现故障,并且在我重新启动 wifi 连接之前它无法工作。所以我的脚本开始引发超时异常,直到我关闭然后打开 wifi 连接。有没有一种有效的方法可以在 osx el capan 上使用 python 2.7 自动打开/关闭 wifi?

python macos wifi python-2.7 phantomjs

2
推荐指数
1
解决办法
2037
查看次数

错误:使用非错误调用done():{}

我正在尝试使用带有Node的Selenium上的Mocha和PhantomJS进行自动测试.我正在使用selenium-webdriver库,因为它似乎是一个受欢迎的库,但是当我运行测试并尝试从页面中提取数据时,它会给我这个错误:

  1) Test "before each" hook for "Test":
     Error: done() invoked with non-Error: {}
      at ManagedPromise.invokeCallback_ (node_modules/selenium-webdriver/lib/promise.js:1379:14)
      at TaskQueue.execute_ (node_modules/selenium-webdriver/lib/promise.js:2913:14)
      at TaskQueue.executeNext_ (node_modules/selenium-webdriver/lib/promise.js:2896:21)
      at node_modules/selenium-webdriver/lib/promise.js:2775:27
      at node_modules/selenium-webdriver/lib/promise.js:639:7
Run Code Online (Sandbox Code Playgroud)

我不确定为什么会出现这个问题,并且搜索没有帮助,因为我的解决方案不符合我的情况; 我上线了:

  • Mac OS X 10
  • Node.js v4.4.5
  • PhantomJS 2.1.1

这是我的脚本:

var selenium = require("selenium-webdriver");
var should = require("should");

var URL = "https://android.com";
var driver;

describe("Test", function() {
    this.timeout(15000);

    beforeEach(function(done) {
        driver = new selenium.Builder()
            .withCapabilities(selenium.Capabilities.phantomjs())
            .build();
        driver.get(URL).then(done);
    });

    /* is this an HTML page? */
    it("Test", function() {
        driver …
Run Code Online (Sandbox Code Playgroud)

javascript testing selenium node.js phantomjs

2
推荐指数
1
解决办法
2864
查看次数

我选择哪一种无头浏览?

我们在前几天使用 phantomjs 用服务器端王子工具生成 pdf。现在我们喜欢把无头浏览器从 phantomjs 换成另一个。

我研究了哪个快速渲染 phantomjs 和 puppeteer。在我的情况下,报告应用程序生成 PDF,只有我使用 puppeteer 和 phantomjs 对其进行测试。phantomjs 与 puppeteer 相比,可以快速处理 HTML。

然后我学习了 google-chrome-headless 选项来生成 PDF。它看起来像一个 Chrome 浏览器 GUI 应用程序的内置模块。我正在使用 nodejs 应用程序。我在命令行中使用以下命令

chrome --headless --disable-gpu --print-to-pdf <src_url>
Run Code Online (Sandbox Code Playgroud)

我注意到 --disable-gpu 选项,其他工具没有。

  • 此选项与其他两个无头浏览器工具(phantomjs、puppeteer)有何不同?
  • 我可以使用哪个工具生成 pdf?

pdf-generation node.js phantomjs google-chrome-headless puppeteer

2
推荐指数
1
解决办法
3031
查看次数