LWP Automated Form Submission - Question
Chong, Arthur (atchong@sbec.com)
Mon, 15 Jan 2001 08:43:09 -0600
I am trying to automate URL submissions into Search Engines.
The format they seem to accept is of GET Forms, with different parameters.
Since I'm scripting this, my URL and Email are variables:
This is the structure I set up:
sub get_urls {
%url = (
altavista => {
lurl =>
"http://add-url.altavista.digital.com/cgi-bin/newurl",
param => [ad => 1,
q => $in_url ]
},
whatyouseek => {
lurl =>
"http://whatuseek.com/cgi-bin/addurl",
param => [ submit => "Add+This+URL",
url => $in_url,
email => $in_email ]
}
);
When I go to call access these, I use the LWP::Simple and URI::URL modules.
I set $in_url (say to http://www.mywebsite.com) and $in_email (to
me@mywebsite.com)
$cnt = 0;
foreach $engine ( sort keys %url) {
$filenm = $filenm.$cnt;
$cnt++;
open (OFILE,$filenm);
print "engine is: $engine :";
for $this_url ( $url{$engine} ) {
print " url is: $this_url->{lurl}";
#print "param: $this_url->{param}"; # cannot print like
this!
my $surl = url ( $this_url->{lurl} ); # this works okay!
$surl->query_form( $this_url->{param} ); # this does not
work?...
$content = get($surl);
print OFILE $content; # answer comes back empty URL and
email...
}
print "\n";
close(OFILE);
}
This code works when I setup for just one hard-coded search-engine:
my $surl = url("http://whatuseek.com/cgi-bin/addurl");
$surl->query_form(submit => "Add+This+URL",
url => $in_url,
email => $in_email );
$content = get ($surl);
print $content;
I guess the problem is how to package the parameters from the
hash-of-hash-of-hash structure into the "query_form" module
call....
Any help much appreciated!! Thank you!
-Arthur.