Subject: | POST method not returning HTTP::Response object . |
Distribution name and version:Scrappy-0.94111370
Perl version:5.10.0
OS:Microsoft Windows XP
I tried following code to extract a web page content using Scrappy post
method.
#START
use strict;
use Scrappy;
my $sess = 'sam.session';
my $scraper1 =Scrappy->new;
-f $sess ? $scraper1->session->load($sess) :
$scraper1->session->write($sess);
my $search_url="http://secure.samford.edu/php-bin/search/dir_susearch.php";
$scraper1->logger->write('log.yml');
$scraper1->post("$search_url",{'searchChar'=>'john','searchBy'=>'ball','roleRadioGp'=>'fall','submit'=>'submit'});
$scraper1->store('sam.html');
#END
But the post method doesn't return any content.It returns only undef
value.So when i try to store the content the following error message shown.
Use of uninitialized value in pattern match (m//) at
C:/Perl/site/lib/Scrappy/Sc
raper.pm line 797.
Use of uninitialized value in pattern match (m//) at
C:/Perl/site/lib/Scrappy/Sc
raper.pm line 797.
Can't call method "content" on an undefined value at
C:/Perl/site/lib/Scrappy/Sc
raper.pm line 811.
Also the message in log file
eventlog: "[2011-05-27 11:19:50] [error] error POSTing data to
http://secure.samford.edu/php-bin/search/dir_susearch.php"
So I checked post method in scraper.pm file and identified the
problem.i.e.,The value stored in @_ value was not available after the
try block .
try {
$self->content($self->worker->post(@_));
};
So I commented the statement as
#try {
$self->content($self->worker->post(@_));
# };
After this I run the script and got the web page content correctly.
But when I try for other sites the post method returns the content but
not the expected one.