in reply to Re^6: Correct link to put in my WWW:Mechanize
in thread Correct link to put in my WWW:Mechanize

Yes, of course, I added some:
my $url = 'http://www.csbio.sjtu.edu.cn/cgi-bin/MEMBRAIN.cgi'; my $mech = WWW::Mechanize->new (timeout=>1000); $mech->get($url); $mech->submit_form ( form_number => 1, fields => { #textarea name | value S1 => ">$id\n$seq", #Radio button name | prediction type R4 => TOPpre, #Radio button SIGNAL | I do not know if I have a signa +l peptide R2 => SignalYES, #Radio button ORGANISM | Human, Plant, Animal, OEuk, G +pos, Gneg, R3 => Human, #Fill in email email => 'testmail@gmail.com' } );

Replies are listed 'Best First'.
Re^8: Correct link to put in my WWW:Mechanize
by bliako (Abbot) on Mar 13, 2022 at 12:14 UTC

    Your code is bad. You need to quote strings (hash values). Additionally S1 parameter looks a bit strange with the new line embedded - are you sure?

    Here is the curl equivalent of a successful run I did earlier (I broke the lines for readability). You can see that by opening developer tools on Firefox. I have done a successful submission using this from a Linux terminal:

    curl 'http://www.csbio.sjtu.edu.cn/cgi-bin/MEMBRAIN.cgi' -H 'User-Agen +t: XXX' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,imag +e/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://www.csbio.sjtu.edu.cn/bioinf/MemBrain/' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Origin: http://www.csbio.sjtu.edu.cn' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: + 1' --data-raw 'mode=string&S1=NTLRVPDILALVIFAVVFLVGVLGNALVVWVTAFEAKRTINAI WFLNLAVADFLACLALPALFTSIVQHHHWPFGGAACSILPSLILLNMYASILLLATISADRFLLVFKPAW CQRFRGAGLAWILCAVAWGLALLLTIPSALYRVVREEYFPPKVLCGVDHDKRRERAVAIVRLVLGFLWPL LTLTICYTFILLRTWSARETRSTKTLKVVVAVVASFFIFWLPYQVTGIMMSFLEPSSPTFLLLKLDSLCV +S FAYINCCINPIIYVVAGQGFQKSLPELLREVLTEESVVR&R5=on&S2=&R4=TOPpre&TOPpre=on &R2=SignalYES&R3=Human&email=abc%40xyz.com&B1=Submit'

    You can infere a couple of things from the above: 1) the correct POST params from --data-raw. 2) No cookies are required. So either continue with Mech but use the correct url and POST params or use LWP::UserAgent with a browser-like user-agent string

    sarcasm on: if the cgi script you are accessing is also programmed by biologists all bets are on (off, whatever).

    bw, bliako

Re^8: Correct link to put in my WWW:Mechanize
by LanX (Saint) on Mar 12, 2022 at 19:15 UTC
    you are still confusing the two URIs, see my explanation here.

    The form is a part of the page you get°

    Maybe you should read up on some HTTP/HTML basics first.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

    °) that's the address you see in your browser, mechanize will extract the address of the CGI automatically if you specify which form to use.

      There is only one form on the page, so I thought it's enough what I write... Usually I had been able to use this script with minimal alterations, for instance for this page:
      http://www.compgen.org/tools/PRED-TMBB2

      (does not have CGI this one). So I think my confusion is created because of the CGI thing.
        WWW::Mechanize shows everything in the synopsis.

        adjust this

        use WWW::Mechanize (); my $mech = WWW::Mechanize->new(); $mech->get( $url ); # the address in your browser $mech->submit_form( form_name => 'search', # the form name in +the code fields => { query => 'pot of gold', }, # parameters button => 'Search Now' # button );

        I'm AFK now, TTYL.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery