in reply to Re: www::mechanize: second "submit" invisible to find_all_submits
in thread www::mechanize: second "submit" invisible to find_all_submits

ah, different url/location ...

you don't need a "submit" button to submit a form

you don't need a "form" object to make a HTTP request (ie submit a form)

https://metacpan.org/pod/WWW::Mechanize#mech-post, $ua->post( $url, $field_name => $value,... Content => $content ) -> POST $url, Header => Value,..., Content => $content, WWW::Mechanize::FAQ, lwpcook, Re^2: POST'ing a large File with LWP::UserAgent

$mech->post( $hypermutUrl, 'FORMAT' => 'FASTA', 'ALIGNMENT' => '', ## 'upfile1' => '', (file) ## [ $file, $filename, Header => Value... ], ## [ undef, $filename, Header => Value,..., Content => $content ], ## [ $filepath, $filenameInHttpHeaderUnrelatedToFilepath, ... ], [ $seqfile , "mahSeqFile$$.fasta" ], 'INN' => '', 'OUT' => '', 'MUTUPSTREAM' => '', 'MUTFROM' => 'G', 'MUTTO' => 'A', 'MUTTO' => 'A', 'MUTDOWNSTREAM' => 'RD', 'ENFORCE' => 'DESCENDANT', 'CONTROLUPSTREAM' => '', 'CONTROLFROM' => 'G', 'CONTROLTO' => 'A', 'CONTROLDOWNSTREAM' => 'YN|RC', 'Analysis' => 'All', 'submit' => 'Run', )
  • Comment on Re^2: www::mechanize: second "submit" invisible to find_all_submits
  • Download Code

Replies are listed 'Best First'.
Re^3: www::mechanize: second "submit" invisible to find_all_submits
by wfischer (Novice) on Dec 08, 2014 at 23:16 UTC

    This excellent suggestion is a good start, but it doesn't get me there. I've altered the code to fit my current understanding, but my $mech object, even after the post, still represents the initial page, not the results page.

    I'm encouraged that I can in fact retrieve the initial page, but discouraged not to be able to get to the results (whether I upload the sequences as a file via the 'upfile1' attribute, or, as below, include them as a text field). Here's what I have:

    #!/usr/bin/perl use warnings; use strict; use WWW::Mechanize; my $hypermutUrl = "http://www.hiv.lanl.gov/content/sequence/HYPERMUT/hypermut.html"; my $mech = WWW::Mechanize->new( autocheck => 1 ); my $alignment_as_string = <<'END_SEQS'; >HIV1-test.CONS ATGGGATGTCTTGGGAATCAGCTGCTTATCGCGCTCTTGCTAGTAAGTGCTTTAGAGATTTATTGTGTTC >HIV1-test.1 ATGGAATGTCTTGGAAATCAGCTGCTTATCGCGCTCTTGCTAGTAAGTGCTTTAAAGATTTATTGTGTTC >HIV1-test.2 ATGGAATGTCTTGGGAATCAGCTGCTTATCGCGCTCTTGCTAGTAAGTGCTTTAAAGATTTATTGTGTTC END_SEQS $mech->post( $hypermutUrl, 'FORMAT' => 'FASTA', 'ALIGNMENT' => $alignment_as_string, 'upfile1' => '', 'INN' => '', 'OUT' => '', 'MUTUPSTREAM' => '', 'MUTFROM' => 'G', 'MUTTO' => 'A', 'MUTDOWNSTREAM' => 'RD', 'ENFORCE' => 'DESCENDANT', 'CONTROLUPSTREAM' => '', 'CONTROLFROM' => 'G', 'CONTROLTO' => 'A', 'CONTROLDOWNSTREAM' => 'YN|RC', 'Analysis' => 'All', 'submit' => 'Run', ); my $page = $mech->content; open my $FH, ">/tmp/hypermut.html"; print {$FH} $page; close $FH; warn "saved webpage data to /tmp/hypermut.html\n";

    I would expect the post operation to add the page resulting from that post to my $mech object -- where am I going wrong?

        Correct, thanks -- using the cgi url (not coincidentally, mech-dump shows it in the POST list) gets an appropriate page back. Unfortunately, it says "Sorry! no sequence input." So I'm still not getting the sequences uploaded -- I'll update if I do get it to go.