Re: www::Mechanize - problems finding forms

Peter Stevens <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Hi,

[forgot to post this to the list ]

Does the compete code have any error checking?  Web servers are far from 
perfect beasts. Sometimes they don't respond, sometimes they don't send 
the content you expect. So if you are striving for reliability, you need to

   1. Verify that the HTTP transaction worked
   2. Verity that the HTML text returned is (more or less) what you
      expected.

(1) is easy - after mech->get, check the mech->status. (2) is harder. 
checking for a string which is likely to appear (only) if you got what 
you were looking for is an approach I have used with success.

If you don't get what you expect, error messages (or for patch 
processing, mail yourself the results). mech->save_content is useful here.

So I would call mech->form, check for success, save the content if it 
doesn't find the form, otherwise fill out the form and submit it....

Hope this helps,

Peter


[email protected] wrote:
> Hi,
>
> Perhaps somebody has an idea how to solve this problem, if its solveable.
>
> I get sometimes this message, after i am running my script:
>
> # There is no form numbered 1 at SwissModel.pm line 26
> # Died at /usr/lib/perl5/site_perl/5.8.8/WWW/Mechanize.pm line 1614, <GEN4194> line 1620.
>
> The part of the code where the error occours. (if complete code is needed just ask for it)
>
> ########
>   my $mech = WWW::Mechanize->new;
> $mech->get('http://swissmodel.expasy.org/workspace/index.php?func=modelling_simple1&userid=USERID&token=TOKEN');
>  
>   $mech->submit_form 
>   (
>   form_number => '1',
>    fields => 
>     {
>   	sequence  => $seq,
>   	group => $temp
>        }       
>   ));
> #########
>
> I have 3 subs in this way, which are executed one after the other.
> The program dies always on an other sub, which are connecting to different pages. once my list was executed completely, but often it do not finish the list.
>
>
> best regards
> Hüseyin
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.