Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

WWW::Mechanize problem

by juanpablog (Initiate)
on Aug 26, 2010 at 12:58 UTC ( [id://857436]=perlquestion: print w/replies, xml ) Need Help??

juanpablog has asked for the wisdom of the Perl Monks concerning the following question:

I have to paste my sequences into the box in http://www.expasy.org/tools/protscale.html and I have to save the result page. So I wrote this perl code which is always retrieve the same page when I change the number in the form_number. How can I fix it? When checking the site the input box is the third form, first one is on right top. Also i didn't write in this code but I have to select one of the preferences below the input box, with dots near them. Also I have to check yes for "Do you want to normalize the scale from 0 to 1?" at the bottom. Thnx in advance
use strict; use WWW::Mechanize; my $url = "http://us.expasy.org/tools/protscale.ht… my $sequence = "GSHMLEDPVVLQRRDWENPGVTQLNRLAA"; my $outfile = "out.htm"; my $mech = WWW::Mechanize->new(); $mech->get($url); $mech->form_number(3); $mech->field(query => "$sequence"); $mech->click(); my $output_page = $mech->content(); open(OUTFILE, ">$outfile"); print OUTFILE "$output_page"; close(OUTFILE);
This code returns as in the page I choose UniProtKB from the drop down menu on the top right and then directly go to the end of the page, inputing nothing to anywhere, and press submit

Replies are listed 'Best First'.
Re: WWW::Mechanize problem
by roboticus (Chancellor) on Aug 26, 2010 at 13:14 UTC

    juanpablog:

    I've never used WWW::Mechanize, but I notice a couple things:

    First, the docs say that you can use click when there's one button on the form, but the provided URL shows two buttons. Are you sure the correct button is being clicked?

    Second, there are examples for WWW::Mechanize that may help you figure out how to select a radio button.

    Third, you do no error checking in your script, so it's possible the code is failing somewhere. You need to check for errors. If it doesn't bite you today, it certainly will in the future...

    ...roboticus

      Thnx, your advices were valuble
Re: WWW::Mechanize problem
by moritz (Cardinal) on Aug 26, 2010 at 13:13 UTC
    So I wrote this perl code which is always retrieve the same page when I change the number in the form_number. How can I fix it?

    Why would you change the form_number? To me it looks like the data you enter always fits for the second form

    Perl 6 - links to (nearly) everything that is Perl 6.
      There are three forms in the site, first one at the right top, my form is the third one

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://857436]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-20 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found