[Chicago-talk] Login
Ed Summers
ehs at pobox.com
Tue Jan 20 16:07:45 CST 2004
petemar1 wrote:
> # :UNRESOLVED: login and scrape with WWW::Search::Ebay::Completed, MMP,
> JAN/20/2004
>
> my $oSearch = new WWW::Search('Ebay::Completed');
>
> $oSearch->login($user, $pass);
>
> my $sQuery = WWW::Search::escape_query("canon digital
> camera -battery -case -cable
> -card -memory -camcorder");
>
> $oSearch->native_query($sQuery);
>
> print $oResult->url, "\n";
>
> $oSearch->logout;
First off, I don't know what Ebay::Completed is. Shouldn't that be
my $oSearch = new WWW::Search( 'Ebay' );
The results of a search (your $oSearch object) can have many results. This
is why the docs [1] tell you to use the next_result() iterator to fetch
them. So instead of:
print $oResult->url, "\n";
You need:
while ( my $oResult = $oSearch->next_result() ) {
print $oResult->url(), "\n";
}
If you were using 'strict' you would've noticed that your $oResult
variable was never declared, because your program wouldn't compile!. There is
rarely a reason not to have this at the top of your Perl program.
use strict;
//Ed
[1] http://search.cpan.org/perldoc?WWW::Search::Ebay
More information about the Chicago-talk
mailing list