PhantomJS在尝试从交互模式运行脚本时说全局代码中的repl-input:1

时间:2015-02-18 01:30:26

标签: ssh terminal 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对象并且fwrite'ing到test.txt

2 个答案:

答案 0 :(得分:2)

PhantomJS有两种命令行模式。您可以在其中运行脚本,也可以在其中运行交互式提示。

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

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

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

我总是发现这并不像预期的那样有效,因为REPL is broken

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

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

您获得的错误是因为此 1 不是有效的JavaScript。

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

答案 1 :(得分:1)

 /bin/phantomjs --proxy=socks://190.40.123.36:8080  /home/engine/public_html/req.js http://example.com/req.php

必须是socks5我认为

状态成功!

相关问题