我在perl脚本上收到以下服务器错误:
格式错误的头从脚本。坏header=:youtube_perl.pl,
这是我的源代码:
#!"C:\XAMPP\perl\bin\perl.exe" -T
use strict;
use warnings;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
use WWW::Mechanize;
my $q = CGI->new;
my $url = 'http://www.youtube.com';
my $mechanize = WWW::Mechanize-&
我想用WWW:Mechanize下载图像,并将它们的尺寸(宽x高,字节)保存到文件名中,但想不出如何将字节提取为可读格式- my $img_bytes =format_bytes(?,precision => 2);谢谢。
use strict;
use warnings;
use File::Basename;
use Data::Dumper;
use Number::Format qw(format_bytes);
use WWW::Mechanize;
my $url = '';
my $mech = WWW::Mechanize->new();
$
我有一台服务器,我可以从它访问网页。我想测试几个用户(比如60000个用户)同时访问同一个网页时的服务器反应。我正在寻找一个脚本来做这件事,perl脚本会更好,
下面是我尝试过的代码
#!c:\\perl\\bin
use strict;
use WWW::Mechanize;
my $url = "http://www.cpan.org";
my $searchstring = "WWW::Mechanize";
my $mech = WWW::Mechanize->new();
while (i == 60000)
{
$mech->get($u
我是Perl的新手,但我在使用perl模块方面有一点专业知识,我曾在HTML::table extract上工作过,但当我处理机械化模块时,它总是告诉我,在运行以下程序时,无法通过package找到对象方法" new“
#!user/Perl/bin;
use strict;
use warnings;
use WWW::Mechanize;
my $URL ="https://accounts.google.com"
我正在尝试修改Perl脚本,以便在每次运行该脚本时创建一个不同的/新的日志文件。我试图按日期创建每个日志文件,但我在合并这个概念时遇到了问题……这就是我到目前为止所知道的:
#!perl -w
use WWW::Mechanize;
# What URL shall we retrieve?
$url = "http://www.mediabase.com/whatsong/whatsong.asp?var_s=075068071069045070077";
# Create a new instance of WWW::Mechanize
# enabling auto
我使用以下代码来获取页面的html。
#!C:\Perl64\bin\perl.exe
use strict;
use warnings;
use WWW::Mechanize;
my $url=$ARGV[0];
my $mech=new WWW::Mechanize();
$mech->get($url,":content_file" => "C:\\path\\www\\page.html");
上述代码在某些站点上运行良好,但其他站点,如维基百科,则需要添加agent_alias。然而,每当我
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use FindBin qw($Bin);
print $Bin;
my $folder = "$Bin/Resources";
mkdir($folder, 0700) unless(-d $folder );
chdir($folder) or die "can't chdir $folder\n";
my $url = 'http://www.ukgamingcomputers.co.uk/images/zalman
为什么WWW::Mechanize在获取以下URL后内容为空?使用浏览器或curl可以检索到完整的超文本标记语言页面。
use WWW::Mechanize;
$mech = new WWW::Mechanize;
$mech->get("http://www.belizejudiciary.org/web/judgements2/");
print $mech->content # prints nothing
下面是响应的转储:
HTTP/1.1 200 OK
Connection: close
Date: Fri, 10 Feb 2017 00:51:47
我编写了以下代码来抓取<div id=aaa-bbb>和下一个</div>标记之间的文本内容,但它只打印出整个HTML源。
use LWP::Simple;
$url = 'http://domain.com/?xxxxxxx';
my $content = get($url);
$data =~ m/<div id="aaa-bbb">(.*?)<\/div>/g;
if (is_success(getprint($url))) {
print $_;
}
# or using the fol
我正在试图找出为什么Perl模块不会安装在我的服务器上。
cpanm WWW::Mechanize
它会处理东西很长时间,最后会随着:
root@admin:~# cpanm WWW::Mechanize
--> Working on WWW::Mechanize
Fetching http://www.cpan.org/authors/id/O/OA/OALDERS/WWW-Mechanize-1.90.tar.gz ... OK
Configuring WWW-Mechanize-1.90 ... OK
Building and testing WWW-Mechanize-1.90
我正在尝试让我在网站上找到的示例代码正常工作:
#!/usr/bin/perl
use v5.10;
use WWW::Mechanize;
use WWW::Mechanize::TreeBuilder;
my $mech = WWW::Mechanize->new;
WWW::Mechanize::TreeBuilder->meta->apply($mech);
$mech->get( 'http://htmlparsing.com/' );
# Find all <h1&
我有一个使用WWW::Mechanize::Firefox的Perl脚本,在使用PAR::Packager将其转换为可执行文件之前,它可以很好地工作。
它将错误显示为
Can't locate MozRepl.pm in @INC
我需要一些建议来解决这个问题,谢谢
@mpapec
更新
use WWW::Mechanize::Firefox;
use HTML::TreeBuilder::XPath;
use MozRepl;
use HTML::Entities ();
use Encode::Byte;
use Encode::Alias;
use Encode::Config
我正在尝试写一个最小的网络爬虫。其目的是从种子中发现新的URL,并进一步爬行这些新的URL。代码如下:
use strict;
use warnings;
use Carp;
use Data::Dumper;
use WWW::Mechanize;
my $url = "http://foobar.com"; # example
my %links;
my $mech = WWW::Mechanize->new(autocheck => 1);
$mech->get($url);
my @cr_fronteir = $mech->find_all_
当我运行这个小示例脚本时,我得到了以下错误:
无法通过包"WWW::Mechanize::Firefox“找到对象方法"new”(可能您忘记加载"WWW::Mechanize::Firefox"?)在mechtest.pl的第二行。
use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new();
$mech->get('http://google.com');
$mech->eval_in_page('alert("Hello Fi
我开始在Perl中处理Web。我使用Windows和ActivePerl。我写了一个脚本,用来下载mp3文件(这是一个电台脱口秀的存档,如果你想知道:),这是合法的(理论上)。
解析网站
收集指向指向数组的mp3文件的所有链接。
遍历数组并下载所有文件。
但是脚本找到了所有的链接,数组没有问题,但是只下载了一个文件。这一定是一个基本的错误,但我找不到。请指出我的错误,谢谢。
use strict;
use warnings;
use WWW::Mechanize;
use LWP::Simple;
use File::Basename;
my $mech = WWW::M
我使用WWW::Mechanize::Shell来测试。
我的代码是:
#!/usr/bin/perl
use WWW::Mechanize;
use HTTP::Cookies;
my $url = "http://mysite/app/login.jsp";
my $username = "username";
my $password = "asdfasdf";
my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech
我正在尝试使用WWW::Mechanize::Chrome下载css/js文件。是的,还有其他方法可以获取这些文件。但我的要求是这要用WWW::Mechanize::Chrome来完成。我想知道这是否可能。 我可以对css或js文件执行$mech->get($url)。然后它会出现在浏览器窗口中,然后我可以使用$mech->content获取该窗口。问题是HTML实体是经过编码的,解码后得到的文件与原始文件不同(我对此进行了测试)。这是js文件的一个问题。之后它们就不能正常运行了。 您可以运行此测试脚本来查看编码后的文件。 use strict;
use warnings;
us
我有代码:
#!/usr/bin/perl
use strict;
use WWW::Mechanize;
my $url = 'http://divxsubtitles.net/page_subtitleinformation.php?ID=111292';
my $m = WWW::Mechanize->new(autocheck => 1);
$m->get($url);
$m->form_number(2);
$m->click();
my $response = $m->res();
print $m->response-&
如何打印正在设置的cookie/cookie_jar的值?
正在尝试:
##my $cookie_jar=HTTP::Cookies->new(file => "cookie.jar",autosave=>1,ignore_discard=>1);
my $cookie_jar=HTTP::Cookies->new(); ## Would like it to be in memory
my $agent = WWW::Mechanize->new(cookie_jar => $cookie_jar);
##my $agent = W
我有一堆网页,我想通过一个脚本导航和抓取所有的内容。我知道这个链接是每个页面上的第18个链接。我有以下代码作为测试,只需跟踪链接一次并抓取屏幕:
use strict;
use WWW::Mechanize;
my $start = "http://*some-webpage*";
my $mech = WWW::Mechanize->new( autocheck => 1 );
$mech->get( $start );
open(Output, ">mech_test.txt") or die $!;
$mech->foll
我有一个简单的要求,屏幕抓取一个网页(简单的URL为基础的报告),并将HTML响应到一个输出文件。但是,URL将重定向到具有“基于表单的”身份验证(没有javascript)的身份验证(HTTPS )页面,并且在身份验证时,我试图查看的报告应该会显示在$response (作为HTML)中。有趣的是,我的代码在Windows机器上运行得很好,但是下面的代码在AIX机器中不起作用,看起来click_button()函数调用什么都不做。我尝试过click(),submit(),但是没有一个在工作,所以没有得到实际的报告,我得到的只是HTML文件中的登录屏幕。任何想法,有什么不对的?
use WWW
我是perl的新手,甚至是机械化的新手。到目前为止,当我尝试通过http获取站点时,没有任何问题。
现在我需要用https来获取一个站点。我已经通过PPM安装了Crypt::SSLeay。
然而,当我使用$mech->get($url)时,我得到的唯一响应是:
"<HTML></HTML>"
我检查了状态和成功,都正常(200和1)。
下面是我的代码:
use strict;
use warnings;
use WWW::Mechanize;
use Crypt::SSLeay;
$ENV{HTTPS_PROXY} = 'http://us
我在AWS上运行两个不同的实例,一个用于节点应用程序,另一个用于mongoDB。我试图在其他实例上连接到mongoDB,但无法连接到"504网关超时“,但失败了。
连接到节点应用程序的db_conf.js如下所示:
var express = require('express');
var mongodb = require('mongodb');
var url = "mongodb://<PUBLIC IP of mongoDB instance>:27017/local";
module.exports = url;
我一直在寻找关于如何从html网页运行perl程序的教程。我找不到一个教程或者一个很好的起点来清楚地解释如何做到这一点……
我想要做的是在perl中使用WWW::mechanize在wordpress站点的后端为我填充一些信息。在我可以这样做之前,我只想看到浏览器中显示的检索到的html,就像实际的网站在浏览器中显示一样。下面是我的perl:
print "Content-type: text/html\n\n";
use CGI;
use WWW::Mechanize;
my $m = WWW::Mechanize->new();
use WWW::Mechani
我是公司的新员工,也是第一次使用Perl。我收到一个任务,其中我通过以下链接找到IP-Reputation:
但在perl中,当我们使用:
#!/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
open FILE1, ">./Reports/Reputation.txt" or die "Cannot open Reputation.txt!";
my $mech = WWW::Mechanize->new( autocheck => 1 );
my $url="http