develooper Front page | perl.libwww | Postings from January 2001

LWP Automated Form Submission - Question

Thread Next
From:
Chong, Arthur
Date:
January 15, 2001 06:36
Subject:
LWP Automated Form Submission - Question
Message ID:
F0736027B8D9D3118D1D009027A83B25C83FD9@SBMAIL1

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.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About