这是我的perl脚本:
#!/usr/local/perl
use strict;
use warnings;
use LWP 5.64;
use HTTP::Cookies;
my $browser=LWP::UserAgent->new;
$browser->agent('Mozilla/5.0'); #etc
my $cookie_jar=HTTP::Cookies->new(
file => '/home/andrew/Documents/Perl/CheckResultsURL/cookies.txt',
autosave => 1,
);
$browser->$cookie_jar($cookie_jar);
my $url="http://scholar.google.com/scholar?hl=en&q=john";
#send request
my $response=$browser->get($url);
if($response->content=~/about(\s)((\d)+)/){
print "yes";
}
print $response->content;
我收到此错误:
Can't locate object method "Cookies=HASH(0x22bf388)" via package "HTTP" at lwp.pl line 17.
可悲的是,我不知道该怎么做。可能它与我没有通过的cookie控件有关。有什么帮助吗?
答案 0 :(得分:3)
我相信行$browser->$cookie_jar($cookie_jar);
应该是$browser->cookie_jar($cookie_jar);
(注意删除额外的'$')