Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Problem submitting a web-form

by Anonymous Monk
on Feb 13, 2018 at 11:38 UTC ( #1209058=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I am trying to write a robot script to submit a web form. Here are the important parts of the form - actual URL is https://rostlab.org/services/nlsdb/:
<textarea class="form-control" name="input-data" id="input-data" rows= +"15"></textarea> <div class="btn-group-lg"> <button type="submit" class="btn btn-primary btn-l +g" id="submit-seq" name="query-seq" value="SFssO806NA96rvTzMiLyoQ" da +ta-toggle="tooltip" title="Search one or more protein sequence(s) for + NES/NLS. Protein sequences must be provided in FASTA format.">Find N +ES/NLS in protein sequence (FASTA)</button> <button type="submit" class="btn btn-primary btn-l +g" id="submit-ac" name="query-ac" value="SFssO806NA96rvTzMiLyoQ" data +-toggle="tooltip" title="Search one or more protein sequence(s) for N +ES/NLS. Protein sequences must be provided by their UniProt AC.">Find + NES/NLS in protein sequence (UniProt AC)</button> <button type="submit" class="btn btn-primary btn-l +g" id="submit-sig1" name="query-sig1" value="SFssO806NA96rvTzMiLyoQ" +data-toggle="tooltip" title="Search NLSdb for all NES/NLS sequences s +imilar to one or more query signal sequence(s).">Find similar NES/NLS + in NLSdb</button> <button type="submit" class="btn btn-primary btn-l +g" id="submit-sig2" name="query-sig2" value="SFssO806NA96rvTzMiLyoQ" +data-toggle="tooltip" title="Evaluate one or more query signal sequen +ce(s) based on the number of nuclear and non-nuclear protein sequence +s they match.">Evaluate NES/NLS</button> </div>

I am interested in (i) pasting 1 sequence in the textarea an (ii) submitting using the "Find NES/NLS in protein sequence (FASTA)" option.
I have written this, but it does not work:
use WWW::Mechanize; my $seq='MAKRGGQLCAGSAPGALGPRSPAPRPLLLLLAGLALVGEARTPGGDGFSLHPPYFNLAEGA +RITASATCGEEAPTRSVSRPTEDLYCKLVGGPVAGGDPNQTIQGQYCDICTAANSNKAHPVSNAIDGTE +RW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RNRLHLSMLVRPHAAS +QGLLLSTAPMSGRSPSLVLFLNHGHFVAQTEGPGPRLQVQSRQHSRAGQWHRVSVRWGMQQIQLVVDGS +QTWSQKALHHRVPRAERPQPYTLSVGGLPASSYSSKLPVSVGFSGCLKKLQLDKRPLRTPTQMVGVTPC +VSGPLEDGLFFPGSEGVVTLELPKAKMPYVSLELEMRPLAAAGLIFHLGQALATPYMQLKVLTEQVLLQ +ANDGAGEFSTWVTYPKLCDGRWHRVAVIMGRDTLRLEVDTQSNHTTGRLPESLAGSPALLHLGSLPKSS +TARPELPAYRGCLRKLLINGAPVNVTASVQIQGAVGMRGCPSGTLALSKQGKALTQRQAKPSVSPLLWH +'; my $url = 'https://rostlab.org/services/nlsdb/'; my $mech = WWW::Mechanize->new(); $mech->get($url); $mech->submit_form ( form_number => 1, fields => { #textarea name | value "input-data" => $seq, #select button "query-seq" => on } ); my $result = $mech->content(); print $result;

I think I am not getting the submit button right, is  "query-seq" => on the correct syntax?

Replies are listed 'Best First'.
Re: Problem submitting a web-form
by 1nickt (Monsignor) on Feb 13, 2018 at 13:59 UTC

    is "query-seq" => on the correct syntax?

    Likely not, since:

    name="query-seq" value="SFssO806NA96rvTzMiLyoQ"
    seems to be what would be sent by a manual submission of the form. But you should check that using the developer tools of your browser.

    Hope this helps!


    The way forward always starts with a minimal test.
Re: Problem submitting a web-form
by Anonymous Monk on Feb 14, 2018 at 14:31 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1209058]
Approved by Corion
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2018-06-22 21:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (124 votes). Check out past polls.

    Notices?