小编GrS*_*Srv的帖子

casperjs在Windows机器上无法正常工作

我有一个casperjs脚本,当我在linux服务器上运行时会给出所需的结果,但是当我从笔记本电脑运行时,它不起作用.

我该如何调试?工作日志:

[info] [phantom] Starting...
[info] [phantom] Running suite: 3 steps
[debug] [phantom] opening url: http://caspertest.grsrv.com/, HTTP GET
[debug] [phantom] Navigation requested: url=http://caspertest.grsrv.com/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://caspertest.grsrv.com/my_app, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=https://caspertest.grsrv.com/my_app/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://caspertest.grsrv.com/my_app/"
[debug] [phantom] Navigation requested: url=https://caspertest.grsrv.com/my_app/#/auth, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://caspertest.grsrv.com/my_app/#/auth"
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/3 https://caspertest.grsrv.com/my_app/#/auth (HTTP 200)
[info] [remote] attempting …
Run Code Online (Sandbox Code Playgroud)

javascript web-scraping phantomjs casperjs

13
推荐指数
1
解决办法
556
查看次数

foreach和特殊变量$ _的行为不符合预期

我正在学习Perl并编写了一个小脚本来打开perl文件并删除注释

# Will remove this comment

my $name = ""; # Will not remove this comment

#!/usr/bin/perl -w < - 不要删除此特别评论

要编辑的文件名称通过终端作为参数传递

die "You need to a give atleast one file-name as an arguement\n" unless (@ARGV);

foreach (@ARGV) {
    $^I = "";
    (-w && open FILE, $_) || die "Oops: $!";
    /^\s*#[^!]/ || print while(<>);
    close FILE;
    print "Done! Please see file: $_\n";
}
Run Code Online (Sandbox Code Playgroud)

现在我通过终端运行它: perl removeComments file1.pl file2.pl file3.pl

我得到了输出: Done! Please see file:

这个脚本正如我所期待的那样完全正常工作

问题1:为什么$_不打印文件名?

问题2:由于循环运行3次,为什么 …

perl

5
推荐指数
1
解决办法
315
查看次数

grep:warning:递归目录循环

我正在使用Xshell来ssh Unix服务器,我正在尝试搜索包含特定文本的文件.

我正在使用的命令是: grep -ilr "blah_blah_text" ./

它找到了我想要的东西,但它也发出了这些警告:

grep:警告:./ snn/pages/dvorak/xhtml/mh370/core/dvorak/found:递归目录循环

grep:警告:./ snn/pages/dvorak/xhtml/mh370/ocean/dvorak/testing/sea:递归目录循环

grep:警告:./ snn/pages/dvorak/xhtml/mh370/asia/dvorak/testing /found:递归目录循环

grep:警告:./ snn/pages/dvorak/xhtml/mh370/ocean/testing/dvorak/found:递归目录循环

grep:警告:./ snn/pages/dvorak/xhtml/mh370/asia/testing/dvorak/monday:递归目录循环

grep:警告:./ snn/pages/dvorak/xhtml/mh370/inse/testing /found:递归目录循环

grep:警告:./ snn/pages/dvorak/xhtml/mh370/testing/dvorak/copa/sea:递归目录循环

grep:警告:./ snv/pages/dvorak/xhtml/mh370/testing/devorak/copa/monday:递归目录循环

grep:警告:./ snn/pages/dvorak/xhtml/mh370/testing/devorak/monday:递归目录循环

grep:警告:./ snn/pages/dvorak/xhtml/mh370/testing/copan/dvorak/found:递归目录循环

grep:警告:./ snn/pages/dvorak/xhtml/mh370/testing/ocean/dvorak/monday:递归目录循环

grep:警告:./ snv/pages/dvorak/xhtml/mh370/testing/copan/monday:递归目录循环

grep:警告:./ snn/pages/gulf/xhtml/qwerty/copa/dvorak/found:递归目录循环

grep:警告:./ snv/pages/gulf/xhtml/qwerty/copa/dvorak/testing/sea:递归目录循环

grep:警告:./ snn/pages/gulf/xhtml/qwerty/copa/dvorak/testing/found:递归目录循环

grep:警告:./ snv/pages/gulf/xhtml/qwerty/copan/testing/dvorak/found:递归目录循环

grep:警告:./ snv/pages/gulf/xhtml/qwerty/copan/testing/dvorak/monday:递归目录循环

grep:警告:./ svn/pages/gulf/xhtml/qwerty/core/testing /found:递归目录循环

grep:警告:./ snn/pages/gulf/xhtml/qwerty/dvorak/copa/sea:递归目录循环

grep:警告:./ snn/pages/gulf/xhtml/qwerty/dvorak/copa/testing/sea:递归目录循环

grep:警告:./ snv/pages/gulf/xhtml/qwerty/dvorak/copa/testing/find:递归目录循环

grep:警告:./ snn/pages/gulf/xhtml/qwerty/dvorak/testing/sea:递归目录循环

grep:警告:./ snn/pages/gulf/xhtml/qwerty/dvorak/testing/core/sea:递归目录循环

grep:警告:./ snv/pages/gulf/xhtml/qwerty/dvorak/testing/copan/monday:递归目录循环

grep:警告:./ snn/pages/india/xhtml/abcd/testing/dvorak/copa/sea:递归目录循环

grep:警告:./ snn/pages/india/xhtml/abcd/testing/dvorak/copa/monday:递归目录循环

grep:警告:./ snn/pages /india/xhtml/abcd/testing/dvorak/monday:递归目录循环

grep:警告:./ snn/pages/india/xhtml/abcd/testing/core/dvorak/found:递归目录循环

grep:警告:./ snn/pages/india/xhtml/abcd/testing/copa/dvorak/monday:递归目录循环

grep:警告:./ snn/pages /india/xhtml/abcd/testing/core/monday:递归目录循环

grep:warning:./ snn/pages /india/xhtml/abcd/dvorak/copa/sea:递归目录循环

grep:警告:./ snn/pages/india/xhtml/abcd/dvorak/copa/testing/sea:递归目录循环

grep:警告:./ snn/pages/india/xhtml/abcd/dvorak/copa/testing/find:递归目录循环 …

unix grep

4
推荐指数
1
解决办法
9385
查看次数

如何将HTML转换为JPEG/PNG

在Perl中是否有办法以IMAGE格式获取URL的内容?

我可以use LWP::Simple获取HTML,但仍然无法弄清楚如何以JPEG格式获取它

perl

3
推荐指数
1
解决办法
1294
查看次数

解除引用运算符 - >不工作

我正在学习参考资料.在中级Perl(第2版):第5章(参考和范围)一书中,给出了以下代码:

my $ref;
{
    my @skipper = qw(blue_shirt hat jacket preserver sunscreen); # ref count is 1
    $ref = \@skipper; # ref count is 2
    print "$ref?>[2]\n"; # prints jacket\n
}
print "$ref?>[2]\n"; # still prints jacket\n # ref count is 1
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,它给出了输出:

ARRAY(0x83fc890)?>[2]

ARRAY(0x83fc890)?>[2]

以为它应该打印夹克.

http://ideone.com/y8ZLsp

当我尝试在没有引号的情况下运行它时,我得到了输出:

Unrecognized character \xE2; marked by <-- HERE after print $ref<-- HERE near column 12 at prog.pl line 5.

http://ideone.com/V9GbUe

我试了一下:

$$ref[2] #Worked

${$ref}[2] #Worked

所以,

书中给出的代码是错误的吗?(我被告知这是一本好书 - 我正在读它,我发现它很棒.不确定这是印刷错误还是我做错了什么)

perl reference

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

标签 统计

perl ×3

casperjs ×1

grep ×1

javascript ×1

phantomjs ×1

reference ×1

unix ×1

web-scraping ×1