I have just started using WWW::Mechanize, so this is a very basic problem, undoubtedly. I have the following code that queries a web service. It is a pretty straightforward query of this page, primer3.
# URL for primer3 my $url = 'http://frodo.wi.mit.edu/cgi-bin/primer3/primer3_www.cgi'; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->get($url); # set up input to form $mech->field('SEQUENCE','ACAGCNTCTGTTGACTCCCCTGCCAGCAAGCCCACTGGCCTGAGC +ACATGAAGTCCTGCACCCAGTCAGGAGAAGGAGCGCTCCTGGCACCAGCAGGAGCTGGCAAAGGCTCTG +GAGAGCTTAGAAAGGGAAAAAATGGAGCTGGAAATGAGGCTAAAGGAGCAGCAGACAGAAATGGAGGCC +ATCCAGGCCCAGAGGGAAGAAGAACGGACCCAGGCAGAGAGTGCCCTATGCCAGATGCAGCTGGAAACA +GAGAAGGAGAGAGTATCCCTCCTGGAGACACTGCTGCAGACGCAGAAGGAGCTAGCAGATGCCAGCCAA +CAACTGGACGGAACTGAGGCAA'); $mech->field('PRIMER_NUM_RETURN',1); # just for debugging purposes print $mech->content(); # Get response by clicking submit button my $resp = $mech->click('Pick Primers'); print "\n\n******* AND Response *********\n\n"; print $resp->content();
No problems except that the "click" method produces the result from the results page:
Did not see the 'Pick Primers' query parameter at /usr/local/apache2/c +gi-bin/primer3/primer3_www_results.cgi line 117 main::main() called at /usr/local/apache2/cgi-bin/primer3/prim +er3_www_results.cgi line 105
I can't figure out why this is the case. The web page works fine interactively and the CGI script that handles the response does a simple check like
if ($query->param('Pick Primers')) { process_input($query); } else { confess "Did not see the 'Pick Primers' query parameter" }
Any help would be much appreciated.

Sean

Update: Does this have anything to do with having a space in the parameter name/value? I have tried this code with a couple of other websites without problems--the only difference seems to be the presence of the space in the parameter name 'Pick Primers'.

In reply to WWW::Mechanize and submit button question by srdst13

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.