【问题标题】:PhantomJS says repl-input:1 in global code when trying to run a script from interactive mode尝试从交互模式运行脚本时,PhantomJS 在全局代码中说 repl-input:1
【发布时间】:2015-02-18 01:30:25
【问题描述】:

在终端中使用 phantomjs 时,我真的很迷茫。我想在代理下访问我的网站并执行 p.js,但它不断吐出我不理解的错误。没有代理它甚至不会去那里..

phantomjs> --proxy=190.40123.36:8080 http://example.com/req.php
Unexpected token '='

phantomjs://repl-input:1 in global code
phantomjs> --proxy=190.40123.36:8080 /home/engine/public_html/p.js http://example.com/req.php
Unexpected token '='

phantomjs://repl-input:1 in global code
phantomjs> --proxy 190.40123.36:8080 /home/engine/public_html/p.js http://example.com/req.php
Unexpected number '190.40123'

phantomjs://repl-input:1 in global code
phantomjs> /home/engine/public_html/p.js http://example.com/req.php
Expected an identifier but found 'http' instead

phantomjs://repl-input:1 in global code
phantomjs> /home/engine/public_html/p.js http://example.com/req.php

什么是全局代码中的 repl-input:1?

我知道即使在最后一个命令中它也没有到达我的站点,因为在 req.php 中我正在获取 php $_SERVER 对象并写入 test.txt

【问题讨论】:

    标签: ssh terminal phantomjs


    【解决方案1】:

    PhantomJS 有两种命令行模式。一种是运行脚本,另一种是有交互式提示。

    您正在做的是运行交互式提示并尝试指定命令行选项和要运行的脚本。

    您可以在启用代理设置的情况下运行交互式提示并尝试以交互方式创建页面:

    $ phantomjs --proxy=ip:port
    phantomjs> var page = require('webpage').create();
    undefined
    phantomjs> ...
    

    我总是发现这并没有按预期工作,因为REPL is broken

    另一种方法是编写一个脚本并使用您的选项以非交互方式运行它:

    $ phantomjs --proxy=ip:port script.js url
    

    您遇到的错误是因为 this1 不是有效的 JavaScript。

    1--proxy=190.40.123.36:8080 /home/engine/public_html/p.js http://example.com/req.php

    【讨论】:

    • 交互式道具显示 Unexpected number '190.40123' 而另一种方式显示 Expected an identifier but found 'proxy'
    • 我刚刚从您的问题中复制了选项。我不知道为什么您的 IP 中缺少一个点。在--proxy 和 IP 之间还必须有一个= 符号。
    • /bin/phantomjs --proxy=190.40.123.36:8080 /home/engine/public_html/p.js example.com/req.php 现在运行命令我看到的只是单词 hello。这他妈到底是什么?我没有在任何地方写你好!
    • 大声笑,对不起,我快疯了。 --proxy=socks://ip:port 是解决方法!!
    【解决方案2】:
     /bin/phantomjs --proxy=socks://190.40.123.36:8080  /home/engine/public_html/req.js http://example.com/req.php
    

    我觉得应该是 socks5

    状态成功!

    【讨论】:

      猜你喜欢
      • 2012-05-16
      • 1970-01-01
      • 1970-01-01
      • 2019-02-27
      • 2016-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-14
      相关资源
      最近更新 更多